lib/fs: Be more clear about invalid file names (ref #7010) (#7011)

Add specific errors for the failures, resulting in this rather than just
the generic "invalid filename":

[MRIW7] 08:50:50 INFO: Puller (folder default, item "NUL"): syncing: filename is invalid: name is reserved
[MRIW7] 08:50:50 INFO: Puller (folder default, item "fail."): syncing: filename is invalid: name ends with space or period
[MRIW7] 08:50:50 INFO: Puller (folder default, item "sup:yo"): syncing: filename is invalid: name contains reserved character
[MRIW7] 08:50:50 INFO: default: Failed to sync 3 items
This commit is contained in:
Jakob Borg
2020-09-28 10:22:50 +02:00
committed by GitHub
parent df99237a7f
commit 9e0b924d57
4 changed files with 22 additions and 17 deletions
+3 -3
View File
@@ -234,7 +234,7 @@ func Canonicalize(file string) (string, error) {
// The relative path may pretend to be an absolute path within
// the root, but the double path separator on Windows implies
// something else and is out of spec.
return "", ErrNotRelative
return "", errNotRelative
}
// The relative path should be clean from internal dotdots and similar
@@ -244,10 +244,10 @@ func Canonicalize(file string) (string, error) {
// It is not acceptable to attempt to traverse upwards.
switch file {
case "..":
return "", ErrNotRelative
return "", errNotRelative
}
if strings.HasPrefix(file, ".."+pathSep) {
return "", ErrNotRelative
return "", errNotRelative
}
if strings.HasPrefix(file, pathSep) {