diff --git a/packages/node_modules/pouchdb-checkpointer/src/index.js b/packages/node_modules/pouchdb-checkpointer/src/index.js index 68e7fa9eb3..e4a3614158 100644 --- a/packages/node_modules/pouchdb-checkpointer/src/index.js +++ b/packages/node_modules/pouchdb-checkpointer/src/index.js @@ -69,41 +69,41 @@ class CheckpointerInternal { if (returnValue.cancelled) { return; - } - // if the checkpoint has not changed, do not update - if (doc.last_seq === checkpoint) { - return; - } + } + // if the checkpoint has not changed, do not update + if (doc.last_seq === checkpoint) { + return; + } - // Filter out current entry for this replication - doc.history = (doc.history || []).filter(item => item.session_id !== session); + // Filter out current entry for this replication + doc.history = (doc.history || []).filter(item => item.session_id !== session); - // Add the latest checkpoint to history - doc.history.unshift({ - last_seq: checkpoint, - session_id: session - }); + // Add the latest checkpoint to history + doc.history.unshift({ + last_seq: checkpoint, + session_id: session + }); - // Just take the last pieces in history, to - // avoid really big checkpoint docs. - // see comment on history size above - doc.history = doc.history.slice(0, CHECKPOINT_HISTORY_SIZE); + // Just take the last pieces in history, to + // avoid really big checkpoint docs. + // see comment on history size above + doc.history = doc.history.slice(0, CHECKPOINT_HISTORY_SIZE); - doc.version = CHECKPOINT_VERSION; - doc.replicator = REPLICATOR; + doc.version = CHECKPOINT_VERSION; + doc.replicator = REPLICATOR; - doc.session_id = session; - doc.last_seq = checkpoint; + doc.session_id = session; + doc.last_seq = checkpoint; - try { - return await db.put(doc); - } catch (err) { - if (err.status === 409) { - // retry; someone is trying to write a checkpoint simultaneously - return this._updateCheckpoint(db, id, checkpoint, session, returnValue); - } - throw err; + try { + return await db.put(doc); + } catch (err) { + if (err.status === 409) { + // retry; someone is trying to write a checkpoint simultaneously + return this._updateCheckpoint(db, id, checkpoint, session, returnValue); } + throw err; + } } async _initCheckpointDoc(db, id, session) { @@ -152,9 +152,9 @@ class CheckpointerInternal { targetDoc = await this.target.get(this.id); } catch (err) { if (err.status !== 404) { - throw err; - } - return LOWEST_SEQ; + throw err; + } + return LOWEST_SEQ; } if (this.opts && this.opts.writeTargetCheckpoint && !this.opts.writeSourceCheckpoint) { @@ -164,8 +164,8 @@ class CheckpointerInternal { try { const sourceDoc = await this.src.get(this.id); // Since we can't migrate an old version doc to a new one - // (no session id), we just go with the lowest seq in this case - /* istanbul ignore if */ + // (no session id), we just go with the lowest seq in this case + /* istanbul ignore if */ if (targetDoc.version !== sourceDoc.version) { return LOWEST_SEQ; }