mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 02:26:42 +01:00
chore: sync generated file immediately (#4538)
A CI failure was observed where a generated file was only partly written when the CI job immediately tried to read it. Put in an fs.Sync call to eliminate this flakiness. Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
This commit is contained in:
parent
11e871566b
commit
83a4528fff
@ -31,6 +31,13 @@ func writeYAMLToFile(path string, rootNode *yaml.Node) error {
|
||||
return fmt.Errorf("failed to close encoder: %w", err)
|
||||
}
|
||||
|
||||
// Sync to ensure data is flushed to disk before subsequent reads.
|
||||
// This prevents flaky test failures on tmpfs where file contents
|
||||
// may not be immediately visible after Close() returns.
|
||||
if err := f.Sync(); err != nil {
|
||||
return fmt.Errorf("failed to sync file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user