Skip to content
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

Sync Fixes #88

Merged
merged 1 commit into from
May 23, 2023
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
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