Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAULT-3226] Use os.rename on windows os #12377

Merged
merged 2 commits into from Aug 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions physical/raft/snapshot.go
Expand Up @@ -9,6 +9,7 @@ import (
"math"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down