Skip to content

Commit

Permalink
compress: fix crash if metadata upload failed - fixes #5994
Browse files Browse the repository at this point in the history
Before this changed the backend attempted to delete a nil object if
the metadata upload failed.
  • Loading branch information
ncw committed Feb 28, 2022
1 parent 8ee0fe9 commit 71a784c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,11 @@ func (f *Fs) putMetadata(ctx context.Context, meta *ObjectMetadata, src fs.Objec
// Put the data
mo, err = put(ctx, metaReader, f.wrapInfo(src, makeMetadataName(src.Remote()), int64(len(data))), options...)
if err != nil {
removeErr := mo.Remove(ctx)
if removeErr != nil {
fs.Errorf(mo, "Failed to remove partially transferred object: %v", err)
if mo != nil {
removeErr := mo.Remove(ctx)
if removeErr != nil {
fs.Errorf(mo, "Failed to remove partially transferred object: %v", err)
}
}
return nil, err
}
Expand Down

0 comments on commit 71a784c

Please sign in to comment.