1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Cli: Added flag to disable local lock when synchronising

This commit is contained in:
Laurent Cozic
2021-06-19 11:41:36 +01:00
parent a86a80b21c
commit 7aff6d271d
2 changed files with 15 additions and 11 deletions

View File

@@ -33,6 +33,7 @@ class Command extends BaseCommand {
return [
['--target <target>', _('Sync to provided target (defaults to sync.target config value)')],
['--upgrade', _('Upgrade the sync target to the latest version.')],
['--use-lock <value>', 'Disable local locks that prevent multiple clients from synchronizing at the same time (Default = 1)'],
];
}
@@ -124,6 +125,9 @@ class Command extends BaseCommand {
const lockFilePath = `${require('os').tmpdir()}/synclock_${md5(escape(Setting.value('profileDir')))}`; // https://github.com/pvorb/node-md5/issues/41
if (!(await fs.pathExists(lockFilePath))) await fs.writeFile(lockFilePath, 'synclock');
const useLock = args.options.useLock !== 0;
if (useLock) {
try {
if (await Command.isLocked(lockFilePath)) throw new Error(_('Synchronisation is already in progress.'));
@@ -136,6 +140,7 @@ class Command extends BaseCommand {
}
throw error;
}
}
const cleanUp = () => {
cliUtils.redrawDone();

View File

@@ -55,5 +55,4 @@ cd "$ROOT_DIR/packages/app-cli"
npm start -- --profile "$PROFILE_DIR" batch "$CMD_FILE"
npm start -- --profile "$PROFILE_DIR" import ~/Desktop/Joplin_17_06_2021.jex
# npm start -- --profile "$PROFILE_DIR" import ~/Desktop/Tout_18_06_2021.jex
npm start -- --profile "$PROFILE_DIR" sync
npm start -- --profile "$PROFILE_DIR" sync --use-lock 1