aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2024-06-15 09:39:49 -0700
committerchrislu <chris.lu@gmail.com>2024-06-15 09:39:49 -0700
commit677cfb8ad1b9c9e0206ae63d568928f9a052a21d (patch)
tree8424f244bad647d7a6357139eed4d56c49b3785f
parent8aae82dd71735df1cd915a47a9b9d453d393adf6 (diff)
downloadseaweedfs-677cfb8ad1b9c9e0206ae63d568928f9a052a21d.tar.xz
seaweedfs-677cfb8ad1b9c9e0206ae63d568928f9a052a21d.zip
refactor
-rw-r--r--weed/filer/filer_deletion.go4
-rw-r--r--weed/server/filer_grpc_server_remote.go2
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go6
-rw-r--r--weed/server/filer_server_handlers_write_cipher.go2
-rw-r--r--weed/server/filer_server_handlers_write_upload.go2
5 files changed, 10 insertions, 6 deletions
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 {