diff --git a/src/restic/fs/file.go b/src/restic/fs/file.go index f6836eb8b..2f6c500b2 100644 --- a/src/restic/fs/file.go +++ b/src/restic/fs/file.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "runtime" + "strings" ) // File is an open file on a file system. @@ -26,7 +27,20 @@ func fixpath(name string) string { if runtime.GOOS == "windows" { abspath, err := filepath.Abs(name) if err == nil { - return "\\\\?\\" + abspath + // Check if \\?\UNC\ already exist + if strings.HasPrefix(abspath, `\\?\UNC\`) { + return abspath + } + // Check if \\?\ already exist + if strings.HasPrefix(abspath, `\\?\`) { + return abspath + } + // Check if path starts with \\ + if strings.HasPrefix(abspath, `\\`) { + return strings.Replace(abspath, `\\`, `\\?\UNC\`, 1) + } + // Normal path + return `\\?\` + abspath } } return name