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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactor
chrislu677cfb8ad1b9
diff --git a/weed/filer/filer_deletion.go b/weed/filer/filer_deletion.goindex ccb7323804..9ea89de2d7 100644--- a/weed/filer/filer_deletion.go+++ b/weed/filer/filer_deletion.go@@ -113,6 +113,10 @@ func (f *Filer) DirectDeleteChunks(chunks []*filer_pb.FileChunk) {f.doDeleteFileIds(fileIdsToDelete)}+func (f *Filer) DeleteUncommittedChunks(chunks []*filer_pb.FileChunk) {+ f.DeleteChunks(chunks)+}+func (f *Filer) DeleteChunks(chunks []*filer_pb.FileChunk) {for _, chunk := range chunks {if !chunk.IsChunkManifest {diff --git a/weed/server/filer_grpc_server_remote.go b/weed/server/filer_grpc_server_remote.goindex 33049a4f47..457d4800af 100644--- a/weed/server/filer_grpc_server_remote.go+++ b/weed/server/filer_grpc_server_remote.go@@ -184,7 +184,7 @@ func (fs *FilerServer) CacheRemoteObjectToLocalCluster(ctx context.Context, req// this skips meta data log eventsif err := fs.filer.Store.UpdateEntry(context.Background(), newEntry); err != nil {- fs.filer.DeleteChunks(chunks)+ fs.filer.DeleteUncommittedChunks(chunks)return nil, err}fs.filer.DeleteChunks(garbage)diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.goindex f4428be61c..4ffc948253 100644--- a/weed/server/filer_server_handlers_write_autochunk.go+++ b/weed/server/filer_server_handlers_write_autochunk.go@@ -102,12 +102,12 @@ func (fs *FilerServer) doPostAutoChunk(ctx context.Context, w http.ResponseWritemd5bytes = md5Hash.Sum(nil)headerMd5 := r.Header.Get("Content-Md5")if headerMd5 != "" && !(util.Base64Encode(md5bytes) == headerMd5 || fmt.Sprintf("%x", md5bytes) == headerMd5) {- fs.filer.DeleteChunks(fileChunks)+ fs.filer.DeleteUncommittedChunks(fileChunks)return nil, nil, errors.New("The Content-Md5 you specified did not match what we received.")}filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)if replyerr != nil {- fs.filer.DeleteChunks(fileChunks)+ fs.filer.DeleteUncommittedChunks(fileChunks)}return@@ -129,7 +129,7 @@ func (fs *FilerServer) doPutAutoChunk(ctx context.Context, w http.ResponseWritermd5bytes = md5Hash.Sum(nil)headerMd5 := r.Header.Get("Content-Md5")if headerMd5 != "" && !(util.Base64Encode(md5bytes) == headerMd5 || fmt.Sprintf("%x", md5bytes) == headerMd5) {- fs.filer.DeleteChunks(fileChunks)+ fs.filer.DeleteUncommittedChunks(fileChunks)return nil, nil, errors.New("The Content-Md5 you specified did not match what we received.")}filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)diff --git a/weed/server/filer_server_handlers_write_cipher.go b/weed/server/filer_server_handlers_write_cipher.goindex 1874a41fc6..6cf7d65b12 100644--- a/weed/server/filer_server_handlers_write_cipher.go+++ b/weed/server/filer_server_handlers_write_cipher.go@@ -91,7 +91,7 @@ func (fs *FilerServer) encrypt(ctx context.Context, w http.ResponseWriter, r *ht}if dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil, false, so.MaxFileNameLength); dbErr != nil {- fs.filer.DeleteChunks(entry.GetChunks())+ fs.filer.DeleteUncommittedChunks(entry.GetChunks())err = dbErrfilerResult.Error = dbErr.Error()returndiff --git a/weed/server/filer_server_handlers_write_upload.go b/weed/server/filer_server_handlers_write_upload.goindex e26eecbe81..8c8eba078b 100644--- a/weed/server/filer_server_handlers_write_upload.go+++ b/weed/server/filer_server_handlers_write_upload.go@@ -132,7 +132,7 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Requewg.Wait()if uploadErr != nil {- fs.filer.DeleteChunks(fileChunks)+ fs.filer.DeleteUncommittedChunks(fileChunks)return nil, md5Hash, 0, uploadErr, nil}slices.SortFunc(fileChunks, func(a, b *filer_pb.FileChunk) int {