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 {
413413
414414 for attachment in attachments {
415415 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- }
421416 continue
422417 }
423418
424419 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
430427 updates. append ( attachment. with (
431428 state: . archived,
432429 localUri: . some( nil ) // Clears the value
433430 ) )
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+ ) )
434436 }
435437 }
436438
You can’t perform that action at this time.
0 commit comments