[mob] Clean up multipart upload on put or update error (#4021)

## Description

## Tests
This commit is contained in:
Neeraj Gupta
2024-11-13 12:01:23 +05:30
committed by GitHub

View File

@@ -820,6 +820,9 @@ class FileUploader {
// file upload can be be retried in such cases without user intervention
uploadHardFailure = false;
}
if (isMultipartUpload && isPutOrUpdateFileError(e)) {
await UploadLocksDB.instance.deleteMultipartTrack(lockKey);
}
rethrow;
} finally {
await _onUploadDone(
@@ -835,6 +838,14 @@ class FileUploader {
}
}
bool isPutOrUpdateFileError(Object e) {
if (e is DioError) {
return e.requestOptions.path.contains("/files") ||
e.requestOptions.path.contains("/files/update");
}
return false;
}
/*
_mapToExistingUpload links the fileToUpload with the existing uploaded
files. if the link is successful, it returns true otherwise false.