1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

Better handling of network errors

This commit is contained in:
Laurent Cozic
2017-07-30 22:22:57 +02:00
parent ad1fbba78d
commit 242b6dbff8
6 changed files with 34 additions and 23 deletions

View File

@@ -126,19 +126,25 @@ reg.scheduleSync = async (delay = null) => {
return;
}
const sync = await reg.synchronizer(syncTargetId);
let context = Setting.value('sync.context');
context = context ? JSON.parse(context) : {};
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;
const sync = await reg.synchronizer(syncTargetId);
let context = Setting.value('sync.context');
context = context ? JSON.parse(context) : {};
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;
}
}
} catch (error) {
reg.logger().info('Could not run background sync: ');
reg.logger().info(error);
}
reg.setupRecurrentSync();