mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-20 20:55:18 +02:00
Per-target sync context
This commit is contained in:
parent
0cf8d3fd74
commit
a5daccce09
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user