mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-18 18:38:08 -05:00
[VAULT-3226] Use os.rename on windows os (#12377)
* [VAULT-3226] Use os.rename on windows os * [VAULT-3226] Add changelog
This commit is contained in:
parent
9659477213
commit
c30db2ca1c
2 changed files with 18 additions and 2 deletions
3
changelog/12377.txt
Normal file
3
changelog/12377.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
```release-note: bug
|
||||
physical/raft: Fix safeio.Rename error when restoring snapshots on windows
|
||||
```
|
||||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -456,7 +457,15 @@ func (s *BoltSnapshotSink) Close() error {
|
|||
|
||||
// Move the directory into place
|
||||
newPath := strings.TrimSuffix(s.dir, tmpSuffix)
|
||||
if err := safeio.Rename(s.dir, newPath); err != nil {
|
||||
|
||||
var err error
|
||||
if runtime.GOOS != "windows" {
|
||||
err = safeio.Rename(s.dir, newPath)
|
||||
} else {
|
||||
err = os.Rename(s.dir, newPath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
s.logger.Error("failed to move snapshot into place", "error", err)
|
||||
return err
|
||||
}
|
||||
|
|
@ -511,7 +520,11 @@ func (i *boltSnapshotInstaller) Install(filename string) error {
|
|||
}
|
||||
|
||||
// Rename the snapshot to the FSM location
|
||||
return safeio.Rename(i.filename, filename)
|
||||
if runtime.GOOS != "windows" {
|
||||
return safeio.Rename(i.filename, filename)
|
||||
} else {
|
||||
return os.Rename(i.filename, filename)
|
||||
}
|
||||
}
|
||||
|
||||
// snapshotName generates a name for the snapshot.
|
||||
|
|
|
|||
Loading…
Reference in a new issue