mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-05 08:52:30 +00:00
fix(cli): show actionable error when sync fails due to locked remote DB
When the remote database is locked and the CLI device is not in the
accepted_nodes list, openReplication returns false with no CLI-specific
guidance. The existing log message ('Fetch rebuilt DB, explicit
unlocking or chunk clean-up is required') is aimed at the Obsidian
plugin UI.
Check the replicator's remoteLockedAndDeviceNotAccepted flag after
sync failure and print a clear message directing the user to unlock
from the Obsidian plugin.
Ref: #832
This commit is contained in:
@@ -21,6 +21,15 @@ export async function runCommand(options: CLIOptions, context: CLICommandContext
|
|||||||
if (options.command === "sync") {
|
if (options.command === "sync") {
|
||||||
console.log("[Command] sync");
|
console.log("[Command] sync");
|
||||||
const result = await core.services.replication.replicate(true);
|
const result = await core.services.replication.replicate(true);
|
||||||
|
if (!result) {
|
||||||
|
const replicator = core.services.replicator.getActiveReplicator();
|
||||||
|
if (replicator?.remoteLockedAndDeviceNotAccepted) {
|
||||||
|
console.error(
|
||||||
|
`[Error] The remote database is locked and this device is not yet accepted.\n` +
|
||||||
|
`[Error] Please unlock the database from the Obsidian plugin and retry.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
return !!result;
|
return !!result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user