mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +00:00
fix #174
This commit is contained in:
parent
c53736566b
commit
b6502ca8d0
1 changed files with 15 additions and 10 deletions
|
|
@ -82,19 +82,25 @@ Future sendMediaFile(
|
|||
}
|
||||
}
|
||||
|
||||
Future retryMediaUpload() async {
|
||||
final lockingHandleMediaFile = Mutex();
|
||||
Future retryMediaUpload({int maxRetries = 3}) async {
|
||||
await lockingHandleMediaFile.protect(() async {
|
||||
final mediaFiles =
|
||||
await twonlyDatabase.mediaUploadsDao.getMediaUploadsForRetry();
|
||||
if (mediaFiles.isEmpty) return;
|
||||
for (final mediaFile in mediaFiles) {
|
||||
await handleSingleMediaFile(mediaFile.mediaUploadId, null);
|
||||
}
|
||||
});
|
||||
if (maxRetries == 0) return;
|
||||
// retry upload
|
||||
Future.delayed(const Duration(milliseconds: 1000), () {
|
||||
retryMediaUpload(maxRetries: maxRetries - 1);
|
||||
});
|
||||
}
|
||||
|
||||
final lockingHandleMediaFile = Mutex();
|
||||
|
||||
Future handleSingleMediaFile(
|
||||
int mediaUploadId, Uint8List? tmpCurrentImageBytes) async {
|
||||
// await lockingHandleMediaFile.protect(() async {
|
||||
MediaUpload? media = await twonlyDatabase.mediaUploadsDao
|
||||
.getMediaUploadById(mediaUploadId)
|
||||
.getSingleOrNull();
|
||||
|
|
@ -156,7 +162,6 @@ Future handleSingleMediaFile(
|
|||
.shout("Non recoverable error while sending media file: $e");
|
||||
return;
|
||||
}
|
||||
// });
|
||||
// this will be called until there is an recoverable error OR
|
||||
// the upload is ready
|
||||
await handleSingleMediaFile(mediaUploadId, tmpCurrentImageBytes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue