[mob] Clean up multipart upload on put or update error (#4021)
## Description ## Tests
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user