File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Sources/PowerSync/attachments Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -413,24 +413,26 @@ open class AttachmentQueue {
413
413
414
414
for attachment in attachments {
415
415
guard let localUri = attachment. localUri else {
416
- // Redownload synced attachments with missing localUri.
417
- // Can happen when the app is reinstalled and a new sandbox is created in the iOS simulator.
418
- if attachment. state == AttachmentState . synced {
419
- updates. append ( attachment. with ( state: . queuedDownload) )
420
- }
421
416
continue
422
417
}
423
418
424
419
let exists = try await localStorage. fileExists ( filePath: localUri)
425
- if attachment. state == AttachmentState . synced ||
426
- attachment. state == AttachmentState . queuedUpload &&
427
- !exists
428
- {
429
- // The file must have been removed from the local storage
420
+ if exists {
421
+ // The file exists, this is correct
422
+ continue
423
+ }
424
+
425
+ if attachment. state == AttachmentState . queuedUpload {
426
+ // The file must have been removed from the local storage before upload was completed
430
427
updates. append ( attachment. with (
431
428
state: . archived,
432
429
localUri: . some( nil ) // Clears the value
433
430
) )
431
+ } else if attachment. state == AttachmentState . synced {
432
+ // The file was downloaded, but removed - trigger redownload
433
+ updates. append ( attachment. with (
434
+ state: . queuedDownload
435
+ ) )
434
436
}
435
437
}
436
438
You can’t perform that action at this time.
0 commit comments