Skip to content

Commit

Permalink
(sync) handle pulling tombstones
Browse files Browse the repository at this point in the history
  • Loading branch information
mistermoe authored and frankhinek committed Jun 6, 2023
1 parent d1afd13 commit bea54af
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/web5-user-agent/src/sync-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,18 @@ export class SyncApi implements SyncManager {
message : recordsRead
}) as RecordsReadReply;

if (reply.status.code >= 400) {
// TODO: handle reply
if (recordsReadReply.status.code >= 400) {
const pruneReply = await this.#dwn.synchronizePrunedInitialRecordsWrite(did, message);

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

continue;
} else {
throw new Error(`Failed to sync tombstone. message cid: ${messageCid}`);
}
} else {
dataStream = webReadableToIsomorphicNodeReadable(recordsReadReply.record.data as any);
}
Expand Down

0 comments on commit bea54af

Please sign in to comment.