Skip to content

Commit

Permalink
file_snapshot: do defer after os.Open succeed (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadoy committed Sep 14, 2022
1 parent 1075246 commit 24e68f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion file_snapshot.go
Expand Up @@ -424,11 +424,11 @@ func (s *FileSnapshotSink) Close() error {

if !s.noSync && runtime.GOOS != "windows" { // skipping fsync for directory entry edits on Windows, only needed for *nix style file systems
parentFH, err := os.Open(s.parentDir)
defer parentFH.Close()
if err != nil {
s.logger.Error("failed to open snapshot parent directory", "path", s.parentDir, "error", err)
return err
}
defer parentFH.Close()

if err = parentFH.Sync(); err != nil {
s.logger.Error("failed syncing parent directory", "path", s.parentDir, "error", err)
Expand Down

0 comments on commit 24e68f8

Please sign in to comment.