mirror of
https://github.com/golang/go.git
synced 2025-05-17 13:24:38 +00:00
cmd/go: always copy files on Windows
Copying ensures that we respect the NTFS permissions of the parent folder. I don't know if there is a way to tell when it is safe to simply rename. Fixes #22343 Change-Id: I424bfe655b53b0e0fe425ce92bbc15450d52d851 Reviewed-on: https://go-review.googlesource.com/72910 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
parent
262141a12a
commit
da360f30e9
@ -18,6 +18,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -1065,6 +1066,14 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
|
|||||||
return b.copyFile(a, dst, src, perm, force)
|
return b.copyFile(a, dst, src, perm, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On Windows, always copy the file, so that we respect the NTFS
|
||||||
|
// permissions of the parent folder. https://golang.org/issue/22343.
|
||||||
|
// What matters here is not cfg.Goos (the system we are building
|
||||||
|
// for) but runtime.GOOS (the system we are building on).
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return b.copyFile(a, dst, src, perm, force)
|
||||||
|
}
|
||||||
|
|
||||||
// If the destination directory has the group sticky bit set,
|
// If the destination directory has the group sticky bit set,
|
||||||
// we have to copy the file to retain the correct permissions.
|
// we have to copy the file to retain the correct permissions.
|
||||||
// https://golang.org/issue/18878
|
// https://golang.org/issue/18878
|
||||||
|
Loading…
x
Reference in New Issue
Block a user