mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
fs: Remove stale background append temporary file (#8404)
Background append creates a temporary file which appends uploaded parts as long as they are available, but when a client stops the upload, the temporary file is not removed by any way. This commit removes the temporary file when the server does its regular removing stale multipart uploads.
This commit is contained in:
parent
c4e2af8ca3
commit
ee05280721
@ -777,6 +777,12 @@ func (fs *FSObjects) cleanupStaleMultipartUploads(ctx context.Context, cleanupIn
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the trailing slash separator
|
||||||
|
for i := range uploadIDs {
|
||||||
|
uploadIDs[i] = strings.TrimSuffix(uploadIDs[i], SlashSeparator)
|
||||||
|
}
|
||||||
|
|
||||||
for _, uploadID := range uploadIDs {
|
for _, uploadID := range uploadIDs {
|
||||||
fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, minioMetaMultipartBucket, entry, uploadID))
|
fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, minioMetaMultipartBucket, entry, uploadID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -787,6 +793,15 @@ func (fs *FSObjects) cleanupStaleMultipartUploads(ctx context.Context, cleanupIn
|
|||||||
// It is safe to ignore any directory not empty error (in case there were multiple uploadIDs on the same object)
|
// It is safe to ignore any directory not empty error (in case there were multiple uploadIDs on the same object)
|
||||||
fsRemoveDir(ctx, pathJoin(fs.fsPath, minioMetaMultipartBucket, entry))
|
fsRemoveDir(ctx, pathJoin(fs.fsPath, minioMetaMultipartBucket, entry))
|
||||||
|
|
||||||
|
// Remove uploadID from the append file map and its corresponding temporary file
|
||||||
|
fs.appendFileMapMu.Lock()
|
||||||
|
bgAppend, ok := fs.appendFileMap[uploadID]
|
||||||
|
if ok {
|
||||||
|
err := fsRemoveFile(ctx, bgAppend.filePath)
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
delete(fs.appendFileMap, uploadID)
|
||||||
|
}
|
||||||
|
fs.appendFileMapMu.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user