diff --git a/CliClient/app/app.js b/CliClient/app/app.js index 7efa2d412d..6969527e67 100644 --- a/CliClient/app/app.js +++ b/CliClient/app/app.js @@ -147,12 +147,6 @@ class Application { continue; } - if (arg == '--autocompletion') { - this.autocompletion_.active = true; - argv.splice(0, 1); - continue; - } - if (arg == '--ac-install') { this.autocompletion_.install = true; argv.splice(0, 1); diff --git a/CliClient/app/autocompletion.js b/CliClient/app/autocompletion.js index e58e308f16..b33d93d8e6 100644 --- a/CliClient/app/autocompletion.js +++ b/CliClient/app/autocompletion.js @@ -25,20 +25,20 @@ function installAutocompletionFile(appName, profileDir) { const filePath = profileDir + '/autocompletion.sh'; fs.writeFileSync(filePath, content); + console.info(_('Created autocompletion script "%s".', filePath)); + const bashProfilePath = os.homedir() + '/.bashrc'; let bashrcContent = fs.readFileSync(bashProfilePath, 'utf8'); const lineToAdd = 'source ' + filePath; - console.info(_('Adding autocompletion script to: "%s"', bashProfilePath)); - if (bashrcContent.indexOf(lineToAdd) >= 0) { - console.info(_('Autocompletion script is already installed.')); + console.info(_('Autocompletion script is already present in "%s".', bashProfilePath)); } else { bashrcContent += "\n" + lineToAdd + "\n"; fs.writeFileSync(bashProfilePath, bashrcContent); - console.info(_('Autocompletion has been installed.')); + console.info(_('Added autocompletion to "%s".', bashProfilePath)); } console.info(_('Sourcing "%s"...', filePath)); diff --git a/CliClient/app/command-sync.js b/CliClient/app/command-sync.js index 4971eb7ac1..e9b3eddfb2 100644 --- a/CliClient/app/command-sync.js +++ b/CliClient/app/command-sync.js @@ -112,13 +112,15 @@ class Command extends BaseCommand { 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) : {}; options.context = context; try { let newContext = await sync.start(options); - Setting.setValue('sync.context', JSON.stringify(newContext)); + Setting.setValue(contextKey, JSON.stringify(newContext)); } catch (error) { if (error.code == 'alreadyStarted') { this.log(error.message); diff --git a/CliClient/locales/en_GB.po b/CliClient/locales/en_GB.po index 3ac444da8e..363e32773f 100644 --- a/CliClient/locales/en_GB.po +++ b/CliClient/locales/en_GB.po @@ -45,13 +45,15 @@ msgid "Only Bash is currently supported for autocompletion." msgstr "" #, javascript-format -msgid "Adding autocompletion script to: \"%s\"" +msgid "Created autocompletion script \"%s\"." msgstr "" -msgid "Autocompletion script is already installed." +#, javascript-format +msgid "Autocompletion script is already present in \"%s\"." msgstr "" -msgid "Autocompletion has been installed." +#, javascript-format +msgid "Added autocompletion to \"%s\"." msgstr "" #, javascript-format diff --git a/CliClient/locales/fr_FR.po b/CliClient/locales/fr_FR.po index f4fd3d9d4f..c4ae3080e2 100644 --- a/CliClient/locales/fr_FR.po +++ b/CliClient/locales/fr_FR.po @@ -47,13 +47,15 @@ msgid "Only Bash is currently supported for autocompletion." msgstr "" #, javascript-format -msgid "Adding autocompletion script to: \"%s\"" +msgid "Created autocompletion script \"%s\"." msgstr "" -msgid "Autocompletion script is already installed." +#, javascript-format +msgid "Autocompletion script is already present in \"%s\"." msgstr "" -msgid "Autocompletion has been installed." +#, javascript-format +msgid "Added autocompletion to \"%s\"." msgstr "" #, javascript-format diff --git a/CliClient/locales/joplin.pot b/CliClient/locales/joplin.pot index 3ac444da8e..363e32773f 100644 --- a/CliClient/locales/joplin.pot +++ b/CliClient/locales/joplin.pot @@ -45,13 +45,15 @@ msgid "Only Bash is currently supported for autocompletion." msgstr "" #, javascript-format -msgid "Adding autocompletion script to: \"%s\"" +msgid "Created autocompletion script \"%s\"." msgstr "" -msgid "Autocompletion script is already installed." +#, javascript-format +msgid "Autocompletion script is already present in \"%s\"." msgstr "" -msgid "Autocompletion has been installed." +#, javascript-format +msgid "Added autocompletion to \"%s\"." msgstr "" #, javascript-format diff --git a/ReactNativeClient/lib/file-api-driver-onedrive.js b/ReactNativeClient/lib/file-api-driver-onedrive.js index 29c261ff82..f10b758a4b 100644 --- a/ReactNativeClient/lib/file-api-driver-onedrive.js +++ b/ReactNativeClient/lib/file-api-driver-onedrive.js @@ -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; diff --git a/ReactNativeClient/lib/joplin-database.js b/ReactNativeClient/lib/joplin-database.js index 4e5f3b41bf..f670f5d602 100644 --- a/ReactNativeClient/lib/joplin-database.js +++ b/ReactNativeClient/lib/joplin-database.js @@ -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); diff --git a/ReactNativeClient/lib/models/setting.js b/ReactNativeClient/lib/models/setting.js index b86d8e1d2c..224f2a2330 100644 --- a/ReactNativeClient/lib/models/setting.js +++ b/ReactNativeClient/lib/models/setting.js @@ -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(); diff --git a/ReactNativeClient/lib/registry.js b/ReactNativeClient/lib/registry.js index c2276ccc37..21e3680166 100644 --- a/ReactNativeClient/lib/registry.js +++ b/ReactNativeClient/lib/registry.js @@ -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);