mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
ctlv3: close snapshot file before rename (Windows)
This commit is contained in:
parent
5c2053109b
commit
fef6557f6c
@ -115,7 +115,7 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
partpath := path + ".part"
|
partpath := path + ".part"
|
||||||
f, err := os.Create(partpath)
|
f, err := os.Create(partpath)
|
||||||
defer f.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exiterr := fmt.Errorf("could not open %s (%v)", partpath, err)
|
exiterr := fmt.Errorf("could not open %s (%v)", partpath, err)
|
||||||
ExitWithError(ExitBadArgs, exiterr)
|
ExitWithError(ExitBadArgs, exiterr)
|
||||||
@ -134,6 +134,8 @@ func snapshotSaveCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
fileutil.Fsync(f)
|
fileutil.Fsync(f)
|
||||||
|
|
||||||
|
f.Close()
|
||||||
|
|
||||||
if rerr := os.Rename(partpath, path); rerr != nil {
|
if rerr := os.Rename(partpath, path); rerr != nil {
|
||||||
exiterr := fmt.Errorf("could not rename %s to %s (%v)", partpath, path, rerr)
|
exiterr := fmt.Errorf("could not rename %s to %s (%v)", partpath, path, rerr)
|
||||||
ExitWithError(ExitIO, exiterr)
|
ExitWithError(ExitIO, exiterr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user