Skip to content

Commit

Permalink
core: only delete attachment file (not the metadata) on sync conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed May 4, 2024
1 parent de6c815 commit 523da4e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/api/sync/merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ class Merger {
isDeleted(localItem) ||
isDeleted(remoteItem) ||
!localItem.dateUploaded ||
!remoteItem.dateUploaded
!remoteItem.dateUploaded ||
localItem.dateUploaded === remoteItem.dateUploaded
) {
return this.mergeItem(remoteItem, localItem);
}

if (localItem.dateUploaded > remoteItem.dateUploaded) return;

const isRemoved = await this.db.attachments.remove(localItem.hash, true);
logger.debug("Removing local attachment file due to conflict", {
hash: localItem.hash
});
const isRemoved = await this.db.fs().deleteFile(localItem.hash, true);
if (!isRemoved)
throw new Error(
"Conflict could not be resolved in one of the attachments."
Expand Down

0 comments on commit 523da4e

Please sign in to comment.