Merge pull request #353 from ente-io/fixQueueBadState

Handle no element stateError while fetching urls
This commit is contained in:
Neeraj Gupta 2022-06-24 09:09:35 +05:30 committed by GitHub
commit f9927653b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;