@@ -317,28 +317,32 @@ export default class GoogleDriveAdapter extends CachingAdapter {
317317 this . fileId = null
318318 }
319319
320- async onSyncComplete ( ) {
321- Logger . log ( 'onSyncComplete' )
322- clearInterval ( this . lockingInterval )
323-
324- this . bookmarksCache = this . bookmarksCache . clone ( false )
325- const newTreeHash = await this . bookmarksCache . hash ( true )
320+ async getXBELContent ( ) {
326321 let xbel = createXBEL ( this . bookmarksCache , this . highestId )
327322
328323 if ( this . server . password ) {
329324 const salt = Crypto . bufferToHexstr ( Crypto . getRandomBytes ( 64 ) )
330325 const ciphertext = await Crypto . encryptAES ( this . server . password , xbel , salt )
331326 xbel = JSON . stringify ( { ciphertext, salt} )
332327 }
328+ return xbel
329+ }
330+
331+ async onSyncComplete ( ) {
332+ Logger . log ( 'onSyncComplete' )
333+ clearInterval ( this . lockingInterval )
334+
335+ this . bookmarksCache = this . bookmarksCache . clone ( false )
336+ const newTreeHash = await this . bookmarksCache . hash ( true )
333337
334338 if ( ! this . fileId ) {
335- await this . createFile ( xbel )
339+ await this . createFile ( await this . getXBELContent ( ) )
336340 this . fileId = null
337341 return
338342 }
339343
340344 if ( newTreeHash !== this . initialTreeHash || this . alwaysUpload ) {
341- await this . uploadFile ( this . fileId , xbel )
345+ await this . uploadFile ( this . fileId , await this . getXBELContent ( ) )
342346 this . alwaysUpload = false // reset flag
343347 } else {
344348 Logger . log ( 'No changes to the server version necessary' )
0 commit comments