Handle no element stateError while fetching urls

This commit is contained in:
Neeraj Gupta 2022-06-24 08:49:31 +05:30
parent 1b9e7dcc13
commit ccd587da3e
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -654,7 +654,16 @@ class FileUploader {
if (_uploadURLs.isEmpty) {
await fetchUploadURLs(_queue.length);
}
return _uploadURLs.removeFirst();
try {
return _uploadURLs.removeFirst();
} catch (e, s) {
if (e is StateError && e.message == 'No element' && _queue.isNotEmpty) {
_logger.warning("Oops, uploadUrls has no element now, fetching again");
return _getUploadURL();
} else {
rethrow;
}
}
}
Future<void> _uploadURLFetchInProgress;