@@ -69,41 +69,41 @@ class CheckpointerInternal {
6969
7070 if ( returnValue . cancelled ) {
7171 return ;
72- }
73- // if the checkpoint has not changed, do not update
74- if ( doc . last_seq === checkpoint ) {
75- return ;
76- }
72+ }
73+ // if the checkpoint has not changed, do not update
74+ if ( doc . last_seq === checkpoint ) {
75+ return ;
76+ }
7777
78- // Filter out current entry for this replication
79- doc . history = ( doc . history || [ ] ) . filter ( item => item . session_id !== session ) ;
78+ // Filter out current entry for this replication
79+ doc . history = ( doc . history || [ ] ) . filter ( item => item . session_id !== session ) ;
8080
81- // Add the latest checkpoint to history
82- doc . history . unshift ( {
83- last_seq : checkpoint ,
84- session_id : session
85- } ) ;
81+ // Add the latest checkpoint to history
82+ doc . history . unshift ( {
83+ last_seq : checkpoint ,
84+ session_id : session
85+ } ) ;
8686
87- // Just take the last pieces in history, to
88- // avoid really big checkpoint docs.
89- // see comment on history size above
90- doc . history = doc . history . slice ( 0 , CHECKPOINT_HISTORY_SIZE ) ;
87+ // Just take the last pieces in history, to
88+ // avoid really big checkpoint docs.
89+ // see comment on history size above
90+ doc . history = doc . history . slice ( 0 , CHECKPOINT_HISTORY_SIZE ) ;
9191
92- doc . version = CHECKPOINT_VERSION ;
93- doc . replicator = REPLICATOR ;
92+ doc . version = CHECKPOINT_VERSION ;
93+ doc . replicator = REPLICATOR ;
9494
95- doc . session_id = session ;
96- doc . last_seq = checkpoint ;
95+ doc . session_id = session ;
96+ doc . last_seq = checkpoint ;
9797
98- try {
99- return await db . put ( doc ) ;
100- } catch ( err ) {
101- if ( err . status === 409 ) {
102- // retry; someone is trying to write a checkpoint simultaneously
103- return this . _updateCheckpoint ( db , id , checkpoint , session , returnValue ) ;
104- }
105- throw err ;
98+ try {
99+ return await db . put ( doc ) ;
100+ } catch ( err ) {
101+ if ( err . status === 409 ) {
102+ // retry; someone is trying to write a checkpoint simultaneously
103+ return this . _updateCheckpoint ( db , id , checkpoint , session , returnValue ) ;
106104 }
105+ throw err ;
106+ }
107107 }
108108
109109 async _initCheckpointDoc ( db , id , session ) {
@@ -152,9 +152,9 @@ class CheckpointerInternal {
152152 targetDoc = await this . target . get ( this . id ) ;
153153 } catch ( err ) {
154154 if ( err . status !== 404 ) {
155- throw err ;
156- }
157- return LOWEST_SEQ ;
155+ throw err ;
156+ }
157+ return LOWEST_SEQ ;
158158 }
159159
160160 if ( this . opts && this . opts . writeTargetCheckpoint && ! this . opts . writeSourceCheckpoint ) {
@@ -164,8 +164,8 @@ class CheckpointerInternal {
164164 try {
165165 const sourceDoc = await this . src . get ( this . id ) ;
166166 // Since we can't migrate an old version doc to a new one
167- // (no session id), we just go with the lowest seq in this case
168- /* istanbul ignore if */
167+ // (no session id), we just go with the lowest seq in this case
168+ /* istanbul ignore if */
169169 if ( targetDoc . version !== sourceDoc . version ) {
170170 return LOWEST_SEQ ;
171171 }
0 commit comments