Clear upload queue if a subscription related error is encountered
This commit is contained in:
parent
2659cb8ebc
commit
3cb2b36c4c
1 changed files with 14 additions and 4 deletions
|
@ -354,7 +354,7 @@ class FileUploader {
|
|||
return file;
|
||||
} on DioError catch (e) {
|
||||
if (e.response.statusCode == 426) {
|
||||
throw StorageLimitExceededError();
|
||||
_onStorageLimitExceeded();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ class FileUploader {
|
|||
return file;
|
||||
} on DioError catch (e) {
|
||||
if (e.response.statusCode == 426) {
|
||||
throw StorageLimitExceededError();
|
||||
_onStorageLimitExceeded();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -434,9 +434,9 @@ class FileUploader {
|
|||
_uploadURLs.addAll(urls);
|
||||
} on DioError catch (e) {
|
||||
if (e.response.statusCode == 402) {
|
||||
throw NoActiveSubscriptionError();
|
||||
_onExpiredSubscription();
|
||||
} else if (e.response.statusCode == 426) {
|
||||
throw StorageLimitExceededError();
|
||||
_onStorageLimitExceeded();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -446,6 +446,16 @@ class FileUploader {
|
|||
return _uploadURLFetchInProgress;
|
||||
}
|
||||
|
||||
void _onStorageLimitExceeded() {
|
||||
clearQueue();
|
||||
throw StorageLimitExceededError();
|
||||
}
|
||||
|
||||
void _onExpiredSubscription() {
|
||||
clearQueue();
|
||||
throw NoActiveSubscriptionError();
|
||||
}
|
||||
|
||||
Future<String> _putFile(
|
||||
UploadURL uploadURL,
|
||||
io.File file, {
|
||||
|
|
Loading…
Add table
Reference in a new issue