You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Per-target sync context
This commit is contained in:
@ -188,7 +188,7 @@ class FileApiDriverOneDrive {
|
||||
items: [],
|
||||
};
|
||||
|
||||
let pathDetails = await this.pathDetails_(path);
|
||||
const pathDetails = await this.pathDetails_(path);
|
||||
const pathId = pathDetails.id;
|
||||
|
||||
let context = options ? options.context : null;
|
||||
|
@ -193,7 +193,7 @@ class JoplinDatabase extends Database {
|
||||
// 1. Add the new version number to the existingDatabaseVersions array
|
||||
// 2. Add the upgrade logic to the "switch (targetVersion)" statement below
|
||||
|
||||
const existingDatabaseVersions = [0, 1, 2, 3];
|
||||
const existingDatabaseVersions = [0, 1, 2, 3, 4];
|
||||
|
||||
let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion);
|
||||
if (currentVersionIndex == existingDatabaseVersions.length - 1) return false;
|
||||
@ -228,6 +228,11 @@ class JoplinDatabase extends Database {
|
||||
queries = this.alterColumnQueries('settings', { key: 'TEXT PRIMARY KEY', value: 'TEXT' });
|
||||
}
|
||||
|
||||
if (targetVersion == 4) {
|
||||
queries.push("INSERT INTO settings (`key`, `value`) VALUES ('sync.3.context', (SELECT `value` FROM settings WHERE `key` = 'sync.context'))");
|
||||
queries.push('DELETE FROM settings WHERE `key` = "sync.context"');
|
||||
}
|
||||
|
||||
queries.push({ sql: 'UPDATE version SET version = ?', params: [targetVersion] });
|
||||
await this.transactionExecBatch(queries);
|
||||
|
||||
|
@ -308,7 +308,12 @@ Setting.metadata_ = {
|
||||
output[Setting.SYNC_TARGET_ONEDRIVE] = _('OneDrive');
|
||||
return output;
|
||||
}},
|
||||
'sync.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.1.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.2.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.3.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.4.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.5.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.6.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'editor': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli'] },
|
||||
'locale': { value: defaultLocale(), type: Setting.TYPE_STRING, isEnum: true, public: true, label: () => _('Language'), options: () => {
|
||||
return supportedLocalesToLanguages();
|
||||
|
@ -161,12 +161,12 @@ reg.scheduleSync = async (delay = null) => {
|
||||
try {
|
||||
const sync = await reg.synchronizer(syncTargetId);
|
||||
|
||||
|
||||
let context = Setting.value('sync.context');
|
||||
const contextKey = 'sync.' + syncTargetId + '.context';
|
||||
let context = Setting.value(contextKey);
|
||||
context = context ? JSON.parse(context) : {};
|
||||
try {
|
||||
let newContext = await sync.start({ context: context });
|
||||
Setting.setValue('sync.context', JSON.stringify(newContext));
|
||||
Setting.setValue(contextKey, JSON.stringify(newContext));
|
||||
} catch (error) {
|
||||
if (error.code == 'alreadyStarted') {
|
||||
reg.logger().info(error.message);
|
||||
|
Reference in New Issue
Block a user