File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ export class Bookmark<L extends TItemLocation> {
8787 async hash ( { preserveOrder = false , hashFn = 'sha256' } : IHashSettings = { preserveOrder : false , hashFn : 'sha256' } ) :Promise < string > {
8888 if ( ! this . hashValue ) {
8989 this . hashValue = { }
90+ }
91+ if ( typeof this . hashValue [ hashFn ] !== 'undefined' ) {
9092 const json = JSON . stringify ( { title : this . title , url : this . url } )
9193 if ( hashFn === 'sha256' ) {
9294 this . hashValue [ hashFn ] = await Crypto . sha256 ( json )
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 SlashError
1616} from '../../errors/Error'
1717import Crypto from '../Crypto'
18+ import { Folder , TItemLocation } from '../Tree'
1819
1920const LOCK_INTERVAL = 2 * 60 * 1000 // Lock every 2mins while syncing
2021const LOCK_TIMEOUT = 15 * 60 * 1000 // Override lock 0.25h after last time lock has been set
@@ -65,6 +66,13 @@ export default class GitAdapter extends CachingAdapter {
6566 this . cancelCallback && this . cancelCallback ( )
6667 }
6768
69+ async getBookmarksTree ( ) : Promise < Folder < TItemLocation > > {
70+ // setHashSettings is called after onSyncStart only but before getBookmarksTree
71+ // thus we get the hash here again
72+ this . initialTreeHash = await this . bookmarksCache . hash ( this . hashSettings )
73+ return super . getBookmarksTree ( )
74+ }
75+
6876 async onSyncStart ( needLock = true , forceLock = false ) {
6977 Logger . log ( 'onSyncStart: begin' )
7078
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212} from '../../errors/Error'
1313import { OAuth2Client } from '@byteowls/capacitor-oauth2'
1414import { Capacitor , CapacitorHttp as Http } from '@capacitor/core'
15+ import { Folder , TItemLocation } from '../Tree'
1516
1617const OAuthConfig = {
1718 authorizationBaseUrl : 'https://accounts.google.com/o/oauth2/auth' ,
@@ -197,6 +198,13 @@ export default class GoogleDriveAdapter extends CachingAdapter {
197198 } )
198199 }
199200
201+ async getBookmarksTree ( ) : Promise < Folder < TItemLocation > > {
202+ // setHashSettings is called after onSyncStart only but before getBookmarksTree
203+ // thus we get the hash here again
204+ this . initialTreeHash = await this . bookmarksCache . hash ( this . hashSettings )
205+ return super . getBookmarksTree ( )
206+ }
207+
200208 async onSyncStart ( needLock = true , forceLock = false ) {
201209 Logger . log ( 'onSyncStart: begin' )
202210
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515import { CapacitorHttp as Http } from '@capacitor/core'
1616import { Capacitor } from '@capacitor/core'
1717import Html from '../serializers/Html'
18+ import { Folder , TItemLocation } from '../Tree'
1819
1920const LOCK_INTERVAL = 2 * 60 * 1000 // Lock every 2mins while syncing
2021const LOCK_TIMEOUT = 15 * 60 * 1000 // Override lock 0.25h after last time lock has been set
@@ -284,6 +285,13 @@ export default class WebDavAdapter extends CachingAdapter {
284285 return response
285286 }
286287
288+ async getBookmarksTree ( ) : Promise < Folder < TItemLocation > > {
289+ // setHashSettings is called after onSyncStart only but before getBookmarksTree
290+ // thus we get the hash here again
291+ this . initialTreeHash = await this . bookmarksCache . hash ( this . hashSettings )
292+ return super . getBookmarksTree ( )
293+ }
294+
287295 async onSyncStart ( needLock = true , forceLock = false ) {
288296 Logger . log ( 'onSyncStart: begin' )
289297 this . ended = false
You can’t perform that action at this time.
0 commit comments