aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbukton <buk_ton2@hotmail.com>2020-04-19 00:31:49 +0700
committerbukton <buk_ton2@hotmail.com>2020-04-19 00:31:49 +0700
commit8c58b0d01764ad7df4a05f5d431657818804f9db (patch)
tree742484dcc31f7de95132d79edc6dbdc33e5ecb81
parentb9a71a5638ea705828478ba928f782b5731cf6c4 (diff)
downloadseaweedfs-8c58b0d01764ad7df4a05f5d431657818804f9db.tar.xz
seaweedfs-8c58b0d01764ad7df4a05f5d431657818804f9db.zip
filer mongodb delete folder children
-rw-r--r--weed/filer2/mongodb/mongodb_store.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.go
index d0d8dcf2c..b9fbd7fa2 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
}