Skip to content

Fix for "access is denied" errors on Windows #984

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions path/winbug.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ func CustomRemoveAll(p string) error {
// at https://github.com/golang/go/issues/20841.
func CustomRename(o, n string) error {

// Handking windows cases first
// Handling windows cases first
if runtime.GOOS == "windows" {
msg.Debug("Detected Windows. Moving files using windows command")
cmd := exec.Command("cmd.exe", "/c", "move", o, n)
msg.Debug("Detected Windows. Moving files using windows command (robocopy)")
cmd := exec.Command("cmd.exe", "/c", "robocopy /s /move /nfl /ndl /njh /njs /nc /ns /np /r:1 /w:1", o, n)
output, err := cmd.CombinedOutput()
if err != nil {
// robocopy exits with 1 for success. See https://ss64.com/nt/robocopy-exit.html
if err != nil && err.Error() != "exit status 1" {
return fmt.Errorf("Error moving files: %s. output: %s", err, output)
}

Expand Down