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.

batch delete file ids

Chris Lub318167cd341
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index f6f0139335..0c0a3e1fa4 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -231,9 +231,11 @@ func (f *Filer) cacheSetDirectory(dirpath string, dirEntry *Entry, level int) {
}
func (f *Filer) DeleteChunks(chunks []*filer_pb.FileChunk) {
+ var fileIds []string
for _, chunk := range chunks {
- f.DeleteFileByFileId(chunk.FileId)
+ fileIds = append(fileIds, chunk.FileId)
}
+ operation.DeleteFiles(f.GetMaster(), fileIds)
}
func (f *Filer) DeleteFileByFileId(fileId string) {
@@ -241,7 +243,7 @@ func (f *Filer) DeleteFileByFileId(fileId string) {
if err != nil {
glog.V(0).Infof("can not find file %s: %v", fileId, err)
}
- if _, err := operation.DeleteFilesAtOneVolumeServer(volumeServer, []string{fileId}); err != nil && err != storage.NotFound{
+ if _, err := operation.DeleteFilesAtOneVolumeServer(volumeServer, []string{fileId}); err != nil && err != storage.NotFound {
glog.V(0).Infof("deleting file %s: %v", fileId, err)
}
}