You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-20 23:30:05 +02:00
31 lines
1020 B
TypeScript
31 lines
1020 B
TypeScript
import JoplinDatabase from '../JoplinDatabase';
|
|
import { MigrationScript } from '../models/Migration';
|
|
import Setting from '../models/Setting';
|
|
import { SyncTargetInfo } from '../services/synchronizer/syncTargetInfoUtils';
|
|
|
|
const script: MigrationScript = {
|
|
|
|
exec: async function(db: JoplinDatabase): Promise<void> {
|
|
const masterKeys = await db.selectAll('SELECT * FROM master_keys');
|
|
|
|
const masterKeyMap: Record<string, any> = {};
|
|
for (const mk of masterKeys) masterKeyMap[mk.id] = mk;
|
|
|
|
const syncInfo: SyncTargetInfo = {
|
|
// When we first setup the local sync target info, we don't know
|
|
// what's on the remote one, so we set it to 0. During sync, the
|
|
// version from remote will be fetched.
|
|
version: 0,
|
|
e2ee: Setting.valueNoThrow('encryption.enabled', false),
|
|
masterKeys: masterKeyMap,
|
|
activeMasterKeyId: Setting.valueNoThrow('encryption.activeMasterKeyId', ''),
|
|
updatedTime: Date.now(),
|
|
};
|
|
|
|
Setting.setValue('sync.info', JSON.stringify(syncInfo));
|
|
},
|
|
|
|
};
|
|
|
|
export default script;
|