From 6a932125032117a1f2275bf68e15b966b18139ed Mon Sep 17 00:00:00 2001 From: Moe Jangda Date: Tue, 23 May 2023 01:18:20 -0500 Subject: [PATCH] minor sync fixes --- packages/web5-user-agent/src/sync-api.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/web5-user-agent/src/sync-api.ts b/packages/web5-user-agent/src/sync-api.ts index 22bfcac2d..257d92fce 100644 --- a/packages/web5-user-agent/src/sync-api.ts +++ b/packages/web5-user-agent/src/sync-api.ts @@ -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); @@ -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[] = []; @@ -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[] = []; @@ -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 });