handle cross-device linking in windows

This commit is contained in:
Gokcehan committed 2020-07-04 00:16:16 +03:00
1 parent e2bf773f3b
commit bc2a80fd6e
3 files changed
+10 -2

No files matched your search

+1 -2
View File
@@ -12,7 +12,6 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"syscall"
"time" "time"
times "gopkg.in/djherbis/times.v1" times "gopkg.in/djherbis/times.v1"
@@ -744,7 +743,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
} }
if err := os.Rename(src, dst); err != nil { if err := os.Rename(src, dst); err != nil {
if err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV { if errCrossDevice(err) {
total, err := copySize([]string{src}) total, err := copySize([]string{src})
if err != nil { if err != nil {
echo.args[0] = err.Error() echo.args[0] = err.Error()
+5
View File
@@ -11,6 +11,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"syscall"
) )
var ( var (
@@ -161,6 +162,10 @@ func matchPattern(pattern, name, path string) bool {
return matched return matched
} }
func errCrossDevice(err error) bool {
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
}
func exportFiles(f string, fs []string) { func exportFiles(f string, fs []string) {
envFile := f envFile := f
envFiles := strings.Join(fs, gOpts.filesep) envFiles := strings.Join(fs, gOpts.filesep)
+4
View File
@@ -119,6 +119,10 @@ func isHidden(f os.FileInfo, path string) bool {
return false return false
} }
func errCrossDevice(err error) bool {
return err.(*os.LinkError).Err.(syscall.Errno) == 17
}
func exportFiles(f string, fs []string) { func exportFiles(f string, fs []string) {
envFile := fmt.Sprintf(`"%s"`, f) envFile := fmt.Sprintf(`"%s"`, f)