1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/lib/services/synchronizer/utils/handleSyncStartupOperation.ts

27 lines
1.0 KiB
TypeScript
Raw Normal View History

import Setting, { SyncStartupOperation } from '../../../models/Setting';
import { clearLocalDataForRedownload, clearLocalSyncStateForReupload } from '../tools';
import { reg } from '../../../registry';
import Logger from '../../../Logger';
const logger = Logger.create('handleSyncStartupOperation');
export default async function() {
logger.info('Processing operation:', Setting.value('sync.startupOperation'));
if (Setting.value('sync.startupOperation') === SyncStartupOperation.ClearLocalSyncState) {
await clearLocalSyncStateForReupload(reg.db());
Setting.setValue('sync.startupOperation', SyncStartupOperation.None);
} else if (Setting.value('sync.startupOperation') === SyncStartupOperation.ClearLocalData) {
await clearLocalDataForRedownload(reg.db());
Setting.setValue('sync.startupOperation', SyncStartupOperation.None);
} else if (Setting.value('sync.startupOperation') === SyncStartupOperation.None) {
// Nothing
} else {
throw new Error(`Invalid sync.startupOperation value: ${Setting.value('sync.startupOperation')}`);
}
}