diff --git a/Sources/PowerSync/attachments/AttachmentQueue.swift b/Sources/PowerSync/attachments/AttachmentQueue.swift index b7aeee2..857d998 100644 --- a/Sources/PowerSync/attachments/AttachmentQueue.swift +++ b/Sources/PowerSync/attachments/AttachmentQueue.swift @@ -417,15 +417,22 @@ open class AttachmentQueue { } let exists = try await localStorage.fileExists(filePath: localUri) - if attachment.state == AttachmentState.synced || - attachment.state == AttachmentState.queuedUpload && - !exists - { - // The file must have been removed from the local storage + if exists { + // The file exists, this is correct + continue + } + + if attachment.state == AttachmentState.queuedUpload { + // The file must have been removed from the local storage before upload was completed updates.append(attachment.with( state: .archived, localUri: .some(nil) // Clears the value )) + } else if attachment.state == AttachmentState.synced { + // The file was downloaded, but removed - trigger redownload + updates.append(attachment.with( + state: .queuedDownload + )) } }