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

All: Better handling of null values in settings

This commit is contained in:
Laurent Cozic
2018-01-07 19:20:10 +00:00
parent 8de5b4219d
commit adc5885980
4 changed files with 23 additions and 6 deletions

View File

@@ -80,7 +80,17 @@ reg.scheduleSync = async (delay = null) => {
const contextKey = 'sync.' + syncTargetId + '.context';
let context = Setting.value(contextKey);
context = context ? JSON.parse(context) : {};
try {
context = context ? JSON.parse(context) : {};
} catch (error) {
// Clearing the context is inefficient since it means all items are going to be re-downloaded
// however it won't result in duplicate items since the synchroniser is going to compare each
// item to the current state.
reg.logger().warn('Could not parse JSON sync context ' + contextKey + ':', context);
reg.logger().info('Clearing context and starting from scratch');
context = null;
}
try {
reg.logger().info('Starting scheduled sync');
let newContext = await sync.start({ context: context });