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.

avoid overwriting file or directory

Chris Luceca078acb86
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index 659054d868..0dde08d04d 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -132,6 +132,12 @@ func (f *Filer) CreateEntry(entry *Entry) error {
return fmt.Errorf("insert entry %s: %v", entry.FullPath, err)
}
} else {
+ if oldEntry.IsDirectory() && !entry.IsDirectory() {
+ return fmt.Errorf("existing %s is a directory", entry.FullPath)
+ }
+ if !oldEntry.IsDirectory() && entry.IsDirectory() {
+ return fmt.Errorf("existing %s is a file", entry.FullPath)
+ }
if err := f.store.UpdateEntry(entry); err != nil {
return fmt.Errorf("update entry %s: %v", entry.FullPath, err)
}