mirror of
https://github.com/octoleo/restic.git
synced 2024-11-05 04:47:51 +00:00
Merge pull request #638 from hmsdao/patch-fixpath
Added long paths fix for samba network shares
This commit is contained in:
commit
6f72164bbe
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// File is an open file on a file system.
|
// File is an open file on a file system.
|
||||||
@ -26,7 +27,20 @@ func fixpath(name string) string {
|
|||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
abspath, err := filepath.Abs(name)
|
abspath, err := filepath.Abs(name)
|
||||||
if err == nil {
|
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
|
return name
|
||||||
|
Loading…
Reference in New Issue
Block a user