diff --git a/weed/filer/filer_deletion.go b/weed/filer/filer_deletion.go index ccb732380..9ea89de2d 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.go index 33049a4f4..457d4800a 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 events if 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.go index f4428be61..4ffc94825 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.ResponseWrite md5bytes = 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.ResponseWriter md5bytes = 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.go index 1874a41fc..6cf7d65b1 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 = dbErr filerResult.Error = dbErr.Error() return diff --git a/weed/server/filer_server_handlers_write_upload.go b/weed/server/filer_server_handlers_write_upload.go index e26eecbe8..8c8eba078 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.Reque wg.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 {