1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

sync in bg

This commit is contained in:
Laurent Cozic
2017-07-24 19:47:01 +00:00
parent a983a9f108
commit 3e1decdfa6
10 changed files with 75 additions and 18 deletions

View File

@@ -115,12 +115,20 @@ reg.scheduleSync = async (delay = null) => {
return;
}
const sync = await reg.synchronizer();
const sync = await reg.synchronizer(Setting.value('sync.target'));
let context = Setting.value('sync.context');
context = context ? JSON.parse(context) : {};
let newContext = await sync.start({ context: context });
Setting.setValue('sync.context', JSON.stringify(newContext));
try {
let newContext = await sync.start({ context: context });
Setting.setValue('sync.context', JSON.stringify(newContext));
} catch (error) {
if (error.code == 'alreadyStarted') {
reg.logger.info(error.message);
} else {
throw error;
}
}
}, delay);
}