local: clean absolute paths - fixes #6493
This commit is contained in:
parent
c0a8ffcbef
commit
f4a571786c
1 changed files with 6 additions and 9 deletions
|
@ -1400,30 +1400,27 @@ func (o *Object) writeMetadata(metadata fs.Metadata) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string {
|
func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS != "windows" || !strings.HasPrefix(s, "\\") {
|
||||||
if !filepath.IsAbs(s) && !strings.HasPrefix(s, "\\") {
|
if !filepath.IsAbs(s) {
|
||||||
s2, err := filepath.Abs(s)
|
s2, err := filepath.Abs(s)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s = s2
|
s = s2
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
s = filepath.Clean(s)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
s = filepath.ToSlash(s)
|
s = filepath.ToSlash(s)
|
||||||
vol := filepath.VolumeName(s)
|
vol := filepath.VolumeName(s)
|
||||||
s = vol + enc.FromStandardPath(s[len(vol):])
|
s = vol + enc.FromStandardPath(s[len(vol):])
|
||||||
s = filepath.FromSlash(s)
|
s = filepath.FromSlash(s)
|
||||||
|
|
||||||
if !noUNC {
|
if !noUNC {
|
||||||
// Convert to UNC
|
// Convert to UNC
|
||||||
s = file.UNCPath(s)
|
s = file.UNCPath(s)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
if !filepath.IsAbs(s) {
|
|
||||||
s2, err := filepath.Abs(s)
|
|
||||||
if err == nil {
|
|
||||||
s = s2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s = enc.FromStandardPath(s)
|
s = enc.FromStandardPath(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue