From 7c2ae4eaf708ebceffca89caa1321470060fd2e0 Mon Sep 17 00:00:00 2001 From: Aarushi Arya Date: Mon, 22 Oct 2018 07:36:30 -0700 Subject: [PATCH] Remove tmp file and multipart folder in FS mode. (#6677) Fixes #6588 --- cmd/fs-v1-multipart.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/fs-v1-multipart.go b/cmd/fs-v1-multipart.go index 65fb6c79e..1d932a9dd 100644 --- a/cmd/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -713,6 +713,11 @@ func (fs *FSObjects) AbortMultipartUpload(ctx context.Context, bucket, object, u } fs.appendFileMapMu.Lock() + // Remove file in tmp folder + file := fs.appendFileMap[uploadID] + if file != nil { + fsRemoveFile(ctx, file.filePath) + } delete(fs.appendFileMap, uploadID) fs.appendFileMapMu.Unlock() @@ -725,10 +730,14 @@ func (fs *FSObjects) AbortMultipartUpload(ctx context.Context, bucket, object, u } return toObjectErr(err, bucket, object) } + // Ignore the error returned as Windows fails to remove directory if a file in it // is Open()ed by the backgroundAppend() fsRemoveAll(ctx, uploadIDDir) + // It is safe to ignore any directory not empty error (in case there were multiple uploadIDs on the same object) + fsRemoveDir(ctx, fs.getMultipartSHADir(bucket, object)) + return nil }