os: Rename on Windows fails if the source directory contains any files or folders #48183
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Windows
What version of Go are you using (
go version
)?go version go1.17 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputGO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/administrator/.cache/go-build"
GOENV="/home/administrator/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/administrator/Documents/Workspaces/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/administrator/Documents/Workspaces/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/administrator/Documents/Workspaces/golang/src/rscraper/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2599231979=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I built a binary for Windows that simply does the following:
Where
directory1
is a folder that contains files or folders, anddirectory2
does not exist yet, and both locations exist under the same parent directory.What did you expect to see?
When running under Windows 10, using CMD as administrator, I expect to see that
directory1
is renamed todirectory2
.What did you see instead?
I get returned the error "access is denied". If the source directory is empty (Contains no files or folders) the rename occurs as expected. I verified that no files or folders are being locked. In addition, when running under Linux (using valid linux paths), everything works as expected and the directory is successfuly renamed in all cases.
If I am wrong, and this is expected behaviour (I don't think it is) I'm not sure how to go about renaming a directory that already contains data (Another fs library perhaps?). But if this is a genuine bug, then this is pretty basic as I'm supprised no one has raised an issue for it. (^_^);
The text was updated successfully, but these errors were encountered: