Skip to content

Commit

Permalink
Merge pull request hashicorp#243 from hashicorp/issue_241_v2s1
Browse files Browse the repository at this point in the history
Disable parent directory fsync on windows
  • Loading branch information
preetapan authored Aug 24, 2017
2 parents 29ea0ff + 8aa7857 commit 2356637
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions file_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -406,17 +407,18 @@ func (s *FileSnapshotSink) Close() error {
return err
}

// fsync the parent directory, to sync directory edits to disk
parentFH, err := os.Open(s.parentDir)
defer parentFH.Close()
if err != nil {
s.logger.Printf("[ERR] snapshot: Failed to open snapshot parent directory %v, error: %v", s.parentDir, err)
return err
}
if 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.Printf("[ERR] snapshot: Failed to open snapshot parent directory %v, error: %v", s.parentDir, err)
return err
}

if err = parentFH.Sync(); err != nil {
s.logger.Printf("[ERR] snapshot: Failed syncing parent directory %v, error: %v", s.parentDir, err)
return err
if err = parentFH.Sync(); err != nil {
s.logger.Printf("[ERR] snapshot: Failed syncing parent directory %v, error: %v", s.parentDir, err)
return err
}
}

// Reap any old snapshots
Expand Down

0 comments on commit 2356637

Please sign in to comment.