Skip to content

Commit

Permalink
fix: resolve module import deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Apr 1, 2024
1 parent 0e63a6c commit 6f6bcea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default class Account {
} else {
// if there is a pending continuation, we resume it

this.syncProcess = DefaultSyncProcess.fromJSON(
this.syncProcess = await DefaultSyncProcess.fromJSON(
mappings,
localResource,
this.server,
Expand Down
8 changes: 5 additions & 3 deletions src/lib/strategies/Default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { TAdapter } from '../interfaces/Adapter'
import { FailsafeError, InterruptedSyncError } from '../../errors/Error'

import NextcloudBookmarksAdapter from '../adapters/NextcloudBookmarks'
import MergeSyncProcess from './Merge'
import UnidirectionalSyncProcess from './Unidirectional'

export default class SyncProcess {
protected mappings: Mappings
Expand Down Expand Up @@ -979,20 +977,24 @@ export default class SyncProcess {
}
}

static fromJSON(mappings:Mappings,
static async fromJSON(mappings:Mappings,
localTree:TLocalTree,
server:TAdapter,
progressCb:(progress:number)=>void,
json: any) {
let strategy: SyncProcess
let MergeSyncProcess: typeof SyncProcess
let UnidirectionalSyncProcess: typeof SyncProcess
switch (json.strategy) {
case 'default':
strategy = new SyncProcess(mappings, localTree, server, progressCb)
break
case 'merge':
MergeSyncProcess = (await import('./Merge')).default
strategy = new MergeSyncProcess(mappings, localTree, server, progressCb)
break
case 'unidirectional':
UnidirectionalSyncProcess = (await import('./Unidirectional')).default
strategy = new UnidirectionalSyncProcess(mappings, localTree, server, progressCb)
}
strategy.setProgress(json)
Expand Down
8 changes: 4 additions & 4 deletions src/lib/strategies/Merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { ItemLocation, TItemLocation } from '../Tree'
import Diff, { Action, ActionType, CreateAction, MoveAction } from '../Diff'
import Scanner from '../Scanner'
import * as Parallel from 'async-parallel'
import Default from './Default'
import DefaultSyncProcess, { ISerializedSyncProcess } from './Default'
import Mappings, { MappingSnapshot } from '../Mappings'
import Logger from '../Logger'

export default class MergeSyncProcess extends Default {
export default class MergeSyncProcess extends DefaultSyncProcess {
async getDiffs():Promise<{localDiff:Diff, serverDiff:Diff}> {
// If there's no cache, diff the two trees directly
const newMappings = []
Expand Down Expand Up @@ -168,9 +168,9 @@ export default class MergeSyncProcess extends Default {
Logger.log('Merge strategy: Load complete tree from server')
this.serverTreeRoot = await this.server.getBookmarksTree(true)
}
toJSON() {
toJSON(): ISerializedSyncProcess {
return {
...Default.prototype.toJSON.apply(this),
...DefaultSyncProcess.prototype.toJSON.apply(this),
strategy: 'merge'
}
}
Expand Down
1 change: 1 addition & 0 deletions test/selenium-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ installConsoleHandler()
}

await driver.get(testUrl)
console.log('Opened test page')

let logs = [],
fin
Expand Down

0 comments on commit 6f6bcea

Please sign in to comment.