Skip to content

Commit

Permalink
minor sync fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mistermoe authored and frankhinek committed May 23, 2023
1 parent 62fb657 commit 6a93212
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/web5-user-agent/src/sync-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class SyncApi implements SyncManager {
message : dwnMessage.message
});

if (reply.status.code === 202) {
if (reply.status.code === 202 || reply.status.code === 409) {
delOps.push({ type: 'del', key: key });
await this.setWatermark(did, dwnUrl, 'push', watermark);
await this.#addMessage(did, messageCid);
Expand All @@ -185,8 +185,6 @@ export class SyncApi implements SyncManager {
}

async enqueuePull() {
await this.enqueuePull();

const profileDids = await this.#db.sublevel('registeredProfiles').keys().all();
const syncStates: SyncState[] = [];

Expand Down Expand Up @@ -243,6 +241,8 @@ export class SyncApi implements SyncManager {
}

async pull() {
await this.enqueuePull();

const pullQueue = this.#getPullQueue();
const pullJobs = await pullQueue.iterator().all();
const delOps: DbBatchOperation[] = [];
Expand Down Expand Up @@ -318,7 +318,7 @@ export class SyncApi implements SyncManager {

const pullReply = await this.#dwn.processMessage(did, entry.message, dataStream);

if (pullReply.status.code === 202) {
if (pullReply.status.code === 202 || pullReply.status.code === 409) {
await this.setWatermark(did, dwnUrl, 'pull', watermark);
await this.#addMessage(did, messageCid);
delOps.push({ type: 'del', key });
Expand Down

0 comments on commit 6a93212

Please sign in to comment.