aboutsummaryrefslogtreecommitdiff
path: root/weed/server/filer_server_handlers_write_autochunk.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-11-29 00:28:26 -0800
committerChris Lu <chris.lu@gmail.com>2021-11-29 00:28:26 -0800
commit88ff8fc27b4b4cca0e813e3ca5bf32fb930f70e3 (patch)
treeb2a94fd50a0ae9e7cc205b84e541ab98f3d4f3d4 /weed/server/filer_server_handlers_write_autochunk.go
parentbea26549f2f54de117bc29b352293c6fe7c1bc49 (diff)
downloadseaweedfs-88ff8fc27b4b4cca0e813e3ca5bf32fb930f70e3.tar.xz
seaweedfs-88ff8fc27b4b4cca0e813e3ca5bf32fb930f70e3.zip
ensure uploaded chunks are deleted on error
Diffstat (limited to 'weed/server/filer_server_handlers_write_autochunk.go')
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.go
index 8d5ef5390..80e623561 100644
--- a/weed/server/filer_server_handlers_write_autochunk.go
+++ b/weed/server/filer_server_handlers_write_autochunk.go
@@ -97,6 +97,9 @@ func (fs *FilerServer) doPostAutoChunk(ctx context.Context, w http.ResponseWrite
md5bytes = md5Hash.Sum(nil)
filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)
+ if replyerr != nil {
+ fs.filer.DeleteChunks(fileChunks)
+ }
return
}
@@ -116,6 +119,9 @@ func (fs *FilerServer) doPutAutoChunk(ctx context.Context, w http.ResponseWriter
md5bytes = md5Hash.Sum(nil)
filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)
+ if replyerr != nil {
+ fs.filer.DeleteChunks(fileChunks)
+ }
return
}
@@ -224,7 +230,6 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
}
if dbErr := fs.filer.CreateEntry(ctx, entry, false, false, nil); dbErr != nil {
- fs.filer.DeleteChunks(fileChunks)
replyerr = dbErr
filerResult.Error = dbErr.Error()
glog.V(0).Infof("failing to write %s to filer server : %v", path, dbErr)