1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/packages/lib/services/synchronizer/utils/handleSyncStartupOperation.ts
2023-07-27 16:08:11 +01:00

27 lines
1.0 KiB
TypeScript

import Setting, { SyncStartupOperation } from '../../../models/Setting';
import { clearLocalDataForRedownload, clearLocalSyncStateForReupload } from '../tools';
import { reg } from '../../../registry';
import Logger from '@joplin/utils/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')}`);
}
}