From 5c7325f44a34b702e1d328e617ec906da60c2ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96rn?= Date: Wed, 5 Oct 2016 07:09:56 +0200 Subject: [PATCH] Added long paths fix for samba network shares --- src/restic/fs/file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/restic/fs/file.go b/src/restic/fs/file.go index f6836eb8b..b11dfb48c 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,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 } }