aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzouyixiong <zouyixiong@gmail.com>2024-09-09 17:15:25 +0800
committerGitHub <noreply@github.com>2024-09-09 02:15:25 -0700
commitd8e18a8eb7746e69b00b6a84e7704d95d8eddb5f (patch)
treeb2a760f7e6b21318557166b901f60079bbf5fc45
parentff3d46637d7adaf364f6384c3d631d16c9741363 (diff)
downloadseaweedfs-d8e18a8eb7746e69b00b6a84e7704d95d8eddb5f.tar.xz
seaweedfs-d8e18a8eb7746e69b00b6a84e7704d95d8eddb5f.zip
bug fixed to filer store elastic deleteEntry (#5988)
-rw-r--r--weed/filer/elastic/v7/elastic_store.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/weed/filer/elastic/v7/elastic_store.go b/weed/filer/elastic/v7/elastic_store.go
index 7bd34852f..1832ddb73 100644
--- a/weed/filer/elastic/v7/elastic_store.go
+++ b/weed/filer/elastic/v7/elastic_store.go
@@ -159,8 +159,16 @@ func (store *ElasticStore) FindEntry(ctx context.Context, fullpath weed_util.Ful
func (store *ElasticStore) DeleteEntry(ctx context.Context, fullpath weed_util.FullPath) (err error) {
index := getIndex(fullpath, false)
id := weed_util.Md5String([]byte(fullpath))
- if strings.Count(string(fullpath), "/") == 1 {
- return store.deleteIndex(ctx, index)
+ strFullpath := string(fullpath)
+
+ // A top-level subdirectory refers to an Elasticsearch index.
+ // If we delete an entry at the top level, we should attempt to delete the corresponding Elasticsearch index.
+ if strings.Count(strFullpath, "/") == 1 {
+ entry, err2 := store.FindEntry(ctx, fullpath)
+ if err2 == nil && entry.IsDirectory() {
+ bucketIndex := indexPrefix + strFullpath[1:]
+ store.deleteIndex(ctx, bucketIndex)
+ }
}
return store.deleteEntry(ctx, index, id)
}