@@ -202,6 +202,7 @@ export default class Account {
202202 const needLock = ( strategy || this . getData ( ) . strategy ) !== 'slave'
203203 let status
204204 try {
205+ Logger . log ( 'Calling onSyncStart' )
205206 status = await this . server . onSyncStart ( needLock , forceSync )
206207 } catch ( e ) {
207208 // Resource locked
@@ -210,6 +211,7 @@ export default class Account {
210211 if ( this . getData ( ) . lastSync < Date . now ( ) - this . lockTimeout || forceSync ) {
211212 // but if we've been waiting for the lock for more than 2h
212213 // start again without locking the resource
214+ Logger . log ( 'Calling onSyncStart, forcing sync' )
213215 status = await this . server . onSyncStart ( false , true )
214216 } else {
215217 await this . setData ( {
@@ -234,13 +236,22 @@ export default class Account {
234236 }
235237
236238 // main sync steps:
239+
240+ Logger . log ( 'Fetching mappings' )
237241 mappings = await this . storage . getMappings ( )
242+ Logger . log ( 'Fetched mappings' )
243+
244+ Logger . log ( 'Fetching cache' )
238245 const cacheTree = await this . storage . getCache ( )
246+ Logger . log ( 'Fetched cache' )
239247
248+ Logger . log ( 'Fetching pending continuation' )
240249 let continuation = await this . storage . getCurrentContinuation ( )
250+ Logger . log ( 'Fetched pending continuation' )
241251
242252 if ( typeof continuation !== 'undefined' && continuation !== null ) {
243253 try {
254+ Logger . log ( 'Attempting to load pending continuation' )
244255 this . syncProcess = await DefaultSyncProcess . fromJSON (
245256 mappings ,
246257 this . localCachingResource ,
@@ -250,6 +261,7 @@ export default class Account {
250261 } ,
251262 continuation
252263 )
264+ Logger . log ( 'Loaded pending continuation' )
253265 } catch ( e ) {
254266 continuation = null
255267 if ( e . message ) Logger . log ( e . message )
@@ -285,6 +297,7 @@ export default class Account {
285297 break
286298 }
287299
300+ Logger . log ( 'Creating new sync process' )
288301 this . syncProcess = new strategyClass (
289302 mappings ,
290303 this . localCachingResource ,
@@ -302,27 +315,35 @@ export default class Account {
302315 Logger . log ( 'Found existing persisted pending continuation. Resuming last sync' )
303316 // When resuming a continuation, the CachingTreeWrapper is usually not initialized yet, because the localTree is
304317 // set from the persisted continuation
318+ Logger . log ( 'Fetching local bookmarks tree' )
319+ this . syncProcess . setCacheTree ( cacheTree )
305320 await this . localCachingResource . setCacheTree ( await this . localCachingResource . getBookmarksTree ( ) )
306321 }
307322
323+ Logger . log ( 'Starting sync process' )
308324 await this . syncProcess . sync ( )
325+ Logger . log ( 'Ended sync process' )
309326
310327 await this . setData ( { scheduled : false , syncing : 1 } )
311328
312329 // update cache
330+ Logger . log ( 'Storing cache' )
313331 const cache = ( await this . localCachingResource . getCacheTree ( ) ) . clone ( false )
314332 this . syncProcess . filterOutUnacceptedBookmarks ( cache )
315333 await this . storage . setCache ( cache )
316334
317335 if ( this . server . onSyncComplete ) {
336+ Logger . log ( 'Calling onSyncComplete' )
318337 await this . server . onSyncComplete ( )
319338 }
320339
321340 if ( mappings ) {
322341 // Remove superfluous items from mappings
323342 // as we don't remove items immediately for anymore (for Atomic adapters), due to possible interrupts
343+ Logger . log ( 'Removing superfluous mappings' )
324344 await mappings . gc ( cache )
325345 // store mappings
346+ Logger . log ( 'Storing mappings' )
326347 await mappings . persist ( )
327348 }
328349
@@ -435,12 +456,18 @@ export default class Account {
435456 if ( actionsDone ) {
436457 const mappings = this . syncProcess . getMappingsInstance ( )
437458 if ( this . server . isAtomic ( ) ) {
459+ Logger . log ( 'progressCallback: Persisting cache' )
438460 const cache = ( await this . localCachingResource . getCacheTree ( ) ) . clone ( false )
439461 this . syncProcess . filterOutUnacceptedBookmarks ( cache )
440462 await this . storage . setCache ( cache )
463+ Logger . log ( 'progressCallback: Persisting mappings' )
441464 await mappings . persist ( )
442465 } else {
443- await this . storage . setCurrentContinuation ( this . syncProcess . toJSON ( ) )
466+ Logger . log ( 'progressCallback: Serializing continuation' )
467+ const cont = await this . syncProcess . toJSONAsync ( )
468+ Logger . log ( 'progressCallback: Persisting continuation' )
469+ await this . storage . setCurrentContinuation ( cont )
470+ Logger . log ( 'progressCallback: Persisting mappings' )
444471 await mappings . persist ( )
445472 }
446473 }
0 commit comments