mirror of
https://github.com/restic/restic.git
synced 2025-12-04 02:41:52 +00:00
mount: Map slashes in tags to underscores
Suggested-by: greatroar <>
This commit is contained in:
@@ -97,6 +97,7 @@ func pathsFromSn(pathTemplate string, timeTemplate string, sn *restic.Snapshot)
|
||||
// needs special treatment: Rebuild the string builders
|
||||
newout := make([]strings.Builder, len(out)*len(sn.Tags))
|
||||
for i, tag := range sn.Tags {
|
||||
tag = filenameFromTag(tag)
|
||||
for j := range out {
|
||||
newout[i*len(out)+j].WriteString(out[j].String() + tag)
|
||||
}
|
||||
@@ -139,6 +140,24 @@ func pathsFromSn(pathTemplate string, timeTemplate string, sn *restic.Snapshot)
|
||||
return paths, timeSuffix
|
||||
}
|
||||
|
||||
// Some tags are problematic when used as filenames:
|
||||
//
|
||||
// ""
|
||||
// ".", ".."
|
||||
// anything containing '/'
|
||||
//
|
||||
// Replace all special character by underscores "_", an empty tag is also represented as a underscore.
|
||||
func filenameFromTag(tag string) string {
|
||||
switch tag {
|
||||
case "", ".":
|
||||
return "_"
|
||||
case "..":
|
||||
return "__"
|
||||
}
|
||||
|
||||
return strings.ReplaceAll(tag, "/", "_")
|
||||
}
|
||||
|
||||
// determine static path prefix
|
||||
func staticPrefix(pathTemplate string) (prefix string) {
|
||||
inVerb := false
|
||||
|
||||
Reference in New Issue
Block a user