forked from TrueCloudLab/restic
Added long paths fix for samba network shares
This commit is contained in:
parent
c45b498a8b
commit
5c7325f44a
1 changed files with 8 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// File is an open file on a file system.
|
||||
|
@ -26,6 +27,13 @@ func fixpath(name string) string {
|
|||
if runtime.GOOS == "windows" {
|
||||
abspath, err := filepath.Abs(name)
|
||||
if err == nil {
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue