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 mongodb delete folder children

bukton8c58b0d01764
diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.go
index d0d8dcf2c2..b9fbd7fa2d 100644
--- a/weed/filer2/mongodb/mongodb_store.go
+++ b/weed/filer2/mongodb/mongodb_store.go
@@ -110,7 +110,9 @@ func (store *MongodbStore) FindEntry(ctx context.Context, fullpath util.FullPath
func (store *MongodbStore) DeleteEntry(ctx context.Context, fullpath util.FullPath) error {
- where := bson.M{"directory": fullpath}
+ dir, name := fullpath.DirAndName()
+
+ where := bson.M{"directory": dir, "name": name}
_, err := store.connect.Database(store.database).Collection(store.collectionName).DeleteOne(ctx, where)
if err != nil {
return fmt.Errorf("delete %s : %v", fullpath, err)
@@ -121,6 +123,12 @@ func (store *MongodbStore) DeleteEntry(ctx context.Context, fullpath util.FullPa
func (store *MongodbStore) DeleteFolderChildren(ctx context.Context, fullpath util.FullPath) error {
+ where := bson.M{"directory": fullpath}
+ _, err := store.connect.Database(store.database).Collection(store.collectionName).DeleteOne(ctx, where)
+ if err != nil {
+ return fmt.Errorf("delete %s : %v", fullpath, err)
+ }
+
return nil
}