Skip to content

Commit

Permalink
ctlv3: close snapshot file before rename (Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinsharat committed Sep 16, 2016
1 parent 5c20531 commit fef6557
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion etcdctl/ctlv3/command/snapshot_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {

partpath := path + ".part"
f, err := os.Create(partpath)
defer f.Close()

if err != nil {
exiterr := fmt.Errorf("could not open %s (%v)", partpath, err)
ExitWithError(ExitBadArgs, exiterr)
Expand All @@ -134,6 +134,8 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {

fileutil.Fsync(f)

f.Close()

if rerr := os.Rename(partpath, path); rerr != nil {
exiterr := fmt.Errorf("could not rename %s to %s (%v)", partpath, path, rerr)
ExitWithError(ExitIO, exiterr)
Expand Down

0 comments on commit fef6557

Please sign in to comment.