Skip to content

Commit 3199de5

Browse files
committed
Fixed IsCrossDeviceError on Windows for direct MoveFileEx call.
Now that we're calling MoveFileEx directly, we no longer unwrap a LinkError created by the os package. Signed-off-by: Jacob Howard <[email protected]>
1 parent 141c196 commit 3199de5

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

pkg/filesystem/directory_windows.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,21 +545,15 @@ func Rename(
545545

546546
const (
547547
// _ERROR_NOT_SAME_DEVICE is the error code returned by MoveFileEx on
548-
// Windows when attempting to move a file across devices. This can actually
549-
// be avoided on Windows by specifying the MOVEFILE_COPY_ALLOWED flag, but
550-
// Go's standard library doesn't do this (most likely to keep consistency
551-
// with POSIX, which has no such facility). Since we don't know the exact
552-
// mechanism by which MOVEFILE_COPY_ALLOWED (i.e. whether or not it uses an
553-
// intermediate file), we avoid using it via a direct call to MoveFileEx.
548+
// Windows when attempting to move a file across devices (without the
549+
// MOVEFILE_COPY_ALLOWED flag being specified).
554550
_ERROR_NOT_SAME_DEVICE = 0x11
555551
)
556552

557553
// IsCrossDeviceError checks whether or not an error returned from rename
558554
// represents a cross-device error.
559555
func IsCrossDeviceError(err error) bool {
560-
if linkErr, ok := err.(*os.LinkError); !ok {
561-
return false
562-
} else if errno, ok := linkErr.Err.(syscall.Errno); !ok {
556+
if errno, ok := err.(syscall.Errno); !ok {
563557
return false
564558
} else {
565559
return errno == _ERROR_NOT_SAME_DEVICE

0 commit comments

Comments
 (0)