mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
Per-target sync context
This commit is contained in:
parent
0cf8d3fd74
commit
a5daccce09
@ -147,12 +147,6 @@ class Application {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg == '--autocompletion') {
|
|
||||||
this.autocompletion_.active = true;
|
|
||||||
argv.splice(0, 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg == '--ac-install') {
|
if (arg == '--ac-install') {
|
||||||
this.autocompletion_.install = true;
|
this.autocompletion_.install = true;
|
||||||
argv.splice(0, 1);
|
argv.splice(0, 1);
|
||||||
|
@ -25,20 +25,20 @@ function installAutocompletionFile(appName, profileDir) {
|
|||||||
const filePath = profileDir + '/autocompletion.sh';
|
const filePath = profileDir + '/autocompletion.sh';
|
||||||
fs.writeFileSync(filePath, content);
|
fs.writeFileSync(filePath, content);
|
||||||
|
|
||||||
|
console.info(_('Created autocompletion script "%s".', filePath));
|
||||||
|
|
||||||
const bashProfilePath = os.homedir() + '/.bashrc';
|
const bashProfilePath = os.homedir() + '/.bashrc';
|
||||||
|
|
||||||
let bashrcContent = fs.readFileSync(bashProfilePath, 'utf8');
|
let bashrcContent = fs.readFileSync(bashProfilePath, 'utf8');
|
||||||
|
|
||||||
const lineToAdd = 'source ' + filePath;
|
const lineToAdd = 'source ' + filePath;
|
||||||
|
|
||||||
console.info(_('Adding autocompletion script to: "%s"', bashProfilePath));
|
|
||||||
|
|
||||||
if (bashrcContent.indexOf(lineToAdd) >= 0) {
|
if (bashrcContent.indexOf(lineToAdd) >= 0) {
|
||||||
console.info(_('Autocompletion script is already installed.'));
|
console.info(_('Autocompletion script is already present in "%s".', bashProfilePath));
|
||||||
} else {
|
} else {
|
||||||
bashrcContent += "\n" + lineToAdd + "\n";
|
bashrcContent += "\n" + lineToAdd + "\n";
|
||||||
fs.writeFileSync(bashProfilePath, bashrcContent);
|
fs.writeFileSync(bashProfilePath, bashrcContent);
|
||||||
console.info(_('Autocompletion has been installed.'));
|
console.info(_('Added autocompletion to "%s".', bashProfilePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info(_('Sourcing "%s"...', filePath));
|
console.info(_('Sourcing "%s"...', filePath));
|
||||||
|
@ -112,13 +112,15 @@ class Command extends BaseCommand {
|
|||||||
|
|
||||||
this.log(_('Starting synchronisation...'));
|
this.log(_('Starting synchronisation...'));
|
||||||
|
|
||||||
let context = Setting.value('sync.context');
|
const contextKey = 'sync.' + this.syncTarget_ + '.context';
|
||||||
|
let context = Setting.value(contextKey);
|
||||||
|
|
||||||
context = context ? JSON.parse(context) : {};
|
context = context ? JSON.parse(context) : {};
|
||||||
options.context = context;
|
options.context = context;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let newContext = await sync.start(options);
|
let newContext = await sync.start(options);
|
||||||
Setting.setValue('sync.context', JSON.stringify(newContext));
|
Setting.setValue(contextKey, JSON.stringify(newContext));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code == 'alreadyStarted') {
|
if (error.code == 'alreadyStarted') {
|
||||||
this.log(error.message);
|
this.log(error.message);
|
||||||
|
@ -45,13 +45,15 @@ msgid "Only Bash is currently supported for autocompletion."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Adding autocompletion script to: \"%s\""
|
msgid "Created autocompletion script \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion script is already installed."
|
#, javascript-format
|
||||||
|
msgid "Autocompletion script is already present in \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion has been installed."
|
#, javascript-format
|
||||||
|
msgid "Added autocompletion to \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
|
@ -47,13 +47,15 @@ msgid "Only Bash is currently supported for autocompletion."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Adding autocompletion script to: \"%s\""
|
msgid "Created autocompletion script \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion script is already installed."
|
#, javascript-format
|
||||||
|
msgid "Autocompletion script is already present in \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion has been installed."
|
#, javascript-format
|
||||||
|
msgid "Added autocompletion to \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
|
@ -45,13 +45,15 @@ msgid "Only Bash is currently supported for autocompletion."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Adding autocompletion script to: \"%s\""
|
msgid "Created autocompletion script \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion script is already installed."
|
#, javascript-format
|
||||||
|
msgid "Autocompletion script is already present in \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Autocompletion has been installed."
|
#, javascript-format
|
||||||
|
msgid "Added autocompletion to \"%s\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
|
@ -188,7 +188,7 @@ class FileApiDriverOneDrive {
|
|||||||
items: [],
|
items: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
let pathDetails = await this.pathDetails_(path);
|
const pathDetails = await this.pathDetails_(path);
|
||||||
const pathId = pathDetails.id;
|
const pathId = pathDetails.id;
|
||||||
|
|
||||||
let context = options ? options.context : null;
|
let context = options ? options.context : null;
|
||||||
|
@ -193,7 +193,7 @@ class JoplinDatabase extends Database {
|
|||||||
// 1. Add the new version number to the existingDatabaseVersions array
|
// 1. Add the new version number to the existingDatabaseVersions array
|
||||||
// 2. Add the upgrade logic to the "switch (targetVersion)" statement below
|
// 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);
|
let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion);
|
||||||
if (currentVersionIndex == existingDatabaseVersions.length - 1) return false;
|
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' });
|
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] });
|
queries.push({ sql: 'UPDATE version SET version = ?', params: [targetVersion] });
|
||||||
await this.transactionExecBatch(queries);
|
await this.transactionExecBatch(queries);
|
||||||
|
|
||||||
|
@ -308,7 +308,12 @@ Setting.metadata_ = {
|
|||||||
output[Setting.SYNC_TARGET_ONEDRIVE] = _('OneDrive');
|
output[Setting.SYNC_TARGET_ONEDRIVE] = _('OneDrive');
|
||||||
return output;
|
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'] },
|
'editor': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli'] },
|
||||||
'locale': { value: defaultLocale(), type: Setting.TYPE_STRING, isEnum: true, public: true, label: () => _('Language'), options: () => {
|
'locale': { value: defaultLocale(), type: Setting.TYPE_STRING, isEnum: true, public: true, label: () => _('Language'), options: () => {
|
||||||
return supportedLocalesToLanguages();
|
return supportedLocalesToLanguages();
|
||||||
|
@ -161,12 +161,12 @@ reg.scheduleSync = async (delay = null) => {
|
|||||||
try {
|
try {
|
||||||
const sync = await reg.synchronizer(syncTargetId);
|
const sync = await reg.synchronizer(syncTargetId);
|
||||||
|
|
||||||
|
const contextKey = 'sync.' + syncTargetId + '.context';
|
||||||
let context = Setting.value('sync.context');
|
let context = Setting.value(contextKey);
|
||||||
context = context ? JSON.parse(context) : {};
|
context = context ? JSON.parse(context) : {};
|
||||||
try {
|
try {
|
||||||
let newContext = await sync.start({ context: context });
|
let newContext = await sync.start({ context: context });
|
||||||
Setting.setValue('sync.context', JSON.stringify(newContext));
|
Setting.setValue(contextKey, JSON.stringify(newContext));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code == 'alreadyStarted') {
|
if (error.code == 'alreadyStarted') {
|
||||||
reg.logger().info(error.message);
|
reg.logger().info(error.message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user