Skip to content

fix attachments not loading in dev environment #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Sources/PowerSync/attachments/AttachmentQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
))
}
}

Expand Down