mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-06-02 08:40:20 +02:00
filer.backup: escape colon from path on windows
fix https://github.com/chrislusf/seaweedfs/issues/2084
This commit is contained in:
parent
ae185b997f
commit
2d7b4e5bb6
|
@ -359,16 +359,19 @@ func genProcessFunction(sourcePath string, targetPath string, dataSink sink.Repl
|
||||||
return processEventFn
|
return processEventFn
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildKey(dataSink sink.ReplicationSink, message *filer_pb.EventNotification, targetPath string, sourceKey util.FullPath, sourcePath string) string {
|
func buildKey(dataSink sink.ReplicationSink, message *filer_pb.EventNotification, targetPath string, sourceKey util.FullPath, sourcePath string) (key string) {
|
||||||
if !dataSink.IsIncremental() {
|
if !dataSink.IsIncremental() {
|
||||||
return util.Join(targetPath, string(sourceKey)[len(sourcePath):])
|
key = util.Join(targetPath, string(sourceKey)[len(sourcePath):])
|
||||||
|
} else {
|
||||||
|
var mTime int64
|
||||||
|
if message.NewEntry != nil {
|
||||||
|
mTime = message.NewEntry.Attributes.Mtime
|
||||||
|
} else if message.OldEntry != nil {
|
||||||
|
mTime = message.OldEntry.Attributes.Mtime
|
||||||
|
}
|
||||||
|
dateKey := time.Unix(mTime, 0).Format("2006-01-02")
|
||||||
|
key = util.Join(targetPath, dateKey, string(sourceKey)[len(sourcePath):])
|
||||||
}
|
}
|
||||||
var mTime int64
|
|
||||||
if message.NewEntry != nil {
|
return escapeKey(key)
|
||||||
mTime = message.NewEntry.Attributes.Mtime
|
|
||||||
} else if message.OldEntry != nil {
|
|
||||||
mTime = message.OldEntry.Attributes.Mtime
|
|
||||||
}
|
|
||||||
dateKey := time.Unix(mTime, 0).Format("2006-01-02")
|
|
||||||
return util.Join(targetPath, dateKey, string(sourceKey)[len(sourcePath):])
|
|
||||||
}
|
}
|
||||||
|
|
7
weed/command/filer_sync_std.go
Normal file
7
weed/command/filer_sync_std.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package command
|
||||||
|
|
||||||
|
func escapeKey(key string) string {
|
||||||
|
return key
|
||||||
|
}
|
12
weed/command/filer_sync_windows.go
Normal file
12
weed/command/filer_sync_windows.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func escapeKey(key string) string {
|
||||||
|
if strings.Contains(key, ":") {
|
||||||
|
return strings.ReplaceAll(key, ":", "")
|
||||||
|
}
|
||||||
|
return key
|
||||||
|
}
|
Loading…
Reference in a new issue