Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer.backup: escape colon from path on windows

Chris Lu2d7b4e5bb6dd
diff --git a/weed/command/filer_sync.go b/weed/command/filer_sync.go
index 0f34e5701e..52fc0b477c 100644
--- a/weed/command/filer_sync.go
+++ b/weed/command/filer_sync.go
@@ -359,16 +359,19 @@ func genProcessFunction(sourcePath string, targetPath string, dataSink sink.Repl
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() {
- return util.Join(targetPath, string(sourceKey)[len(sourcePath):])
- }
- var mTime int64
- if message.NewEntry != nil {
- mTime = message.NewEntry.Attributes.Mtime
- } else if message.OldEntry != nil {
- mTime = message.OldEntry.Attributes.Mtime
+ 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):])
}
- dateKey := time.Unix(mTime, 0).Format("2006-01-02")
- return util.Join(targetPath, dateKey, string(sourceKey)[len(sourcePath):])
+
+ return escapeKey(key)
}
diff --git a/weed/command/filer_sync_std.go b/weed/command/filer_sync_std.go
new file mode 100644
index 0000000000..63851eaf85
--- /dev/null
+++ b/weed/command/filer_sync_std.go
@@ -0,0 +1,7 @@
+// +build !windows
+
+package command
+
+func escapeKey(key string) string {
+ return key
+}
diff --git a/weed/command/filer_sync_windows.go b/weed/command/filer_sync_windows.go
new file mode 100644
index 0000000000..3d0c9146ec
--- /dev/null
+++ b/weed/command/filer_sync_windows.go
@@ -0,0 +1,12 @@
+package command
+
+import (
+ "strings"
+)
+
+func escapeKey(key string) string {
+ if strings.Contains(key, ":") {
+ return strings.ReplaceAll(key, ":", "")
+ }
+ return key
+}