Browse Source

refactor

pull/4508/merge
chrislu 6 months ago
parent
commit
677cfb8ad1
  1. 4
      weed/filer/filer_deletion.go
  2. 2
      weed/server/filer_grpc_server_remote.go
  3. 6
      weed/server/filer_server_handlers_write_autochunk.go
  4. 2
      weed/server/filer_server_handlers_write_cipher.go
  5. 2
      weed/server/filer_server_handlers_write_upload.go

4
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 {

2
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)

6
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)

2
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

2
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 {

Loading…
Cancel
Save