Warn after partial startup scans

This commit is contained in:
vorotamoroz
2026-09-04 13:54:36 +00:00
parent 6abc5cba64
commit 188b749326
8 changed files with 53 additions and 9 deletions
+5 -2
View File
@@ -15,7 +15,10 @@ import { stripAllPrefixes } from "@vrtmrz/livesync-commonlib/compat/string_and_b
import type { CLICommandContext, CLIOptions } from "./types";
import { toArrayBuffer, toDatabaseRelativePath } from "./utils";
import { collectPeers, openP2PHost, parseTimeoutSeconds, syncWithPeer } from "./p2p";
import { performFullScan } from "@vrtmrz/livesync-commonlib/compat/serviceFeatures/offlineScanner";
import {
performFullScan,
VaultScanResults,
} from "@vrtmrz/livesync-commonlib/compat/serviceFeatures/offlineScanner";
import { UnresolvedErrorManager } from "@vrtmrz/livesync-commonlib/compat/services/base/UnresolvedErrorManager";
import { compatGlobal } from "@vrtmrz/livesync-commonlib/compat/common/coreEnvFunctions";
import { fsPromises as fs, path } from "@vrtmrz/livesync-commonlib/node";
@@ -529,7 +532,7 @@ export async function runCommand(options: CLIOptions, context: CLICommandContext
writeStderrLine(standardIo, "[Command] mirror");
const log = (msg: unknown) => writeStderrLine(standardIo, `[Mirror] ${String(msg)}`);
const errorManager = new UnresolvedErrorManager(core.services.appLifecycle, core.services.context.events);
return await performFullScan(core, log, errorManager, false, true);
return (await performFullScan(core, log, errorManager, false, true)) === VaultScanResults.COMPLETED;
}
if (options.command === "remote-add") {
+4 -1
View File
@@ -10418,7 +10418,7 @@ export const allMessages: Readonly<Record<string, Readonly<Record<string, string
"zh-tw": "使用遠端設定",
},
"Ui.Common.LocalDatabaseInitialisationFailed": {
def: "Local database initialisation did not complete. See the log for details.",
def: "Self-hosted LiveSync cannot synchronise. Generate a report to review the detailed log.",
},
"Ui.Common.Signal.Caution": {
def: "CAUTION",
@@ -10448,6 +10448,9 @@ export const allMessages: Readonly<Record<string, Readonly<Record<string, string
zh: "警告",
"zh-tw": "警告",
},
"Ui.Common.SomeFilesCouldNotBeSynchronised": {
def: "Not all files could be synchronised. Check the affected files. Generate a report to review the detailed log.",
},
"Ui.Settings.Advanced.LocalDatabaseTweak": {
def: "Local Database Tweak",
es: "Ajuste fino de la base de datos local",
+2 -1
View File
@@ -1143,11 +1143,12 @@
"TweakMismatchResolve.Title.AutoAcceptCompatible": "Auto-Accept Available",
"TweakMismatchResolve.Title.TweakResolving": "Configuration Mismatch Detected",
"TweakMismatchResolve.Title.UseRemoteConfig": "Use Remote Configuration",
"Ui.Common.LocalDatabaseInitialisationFailed": "Local database initialisation did not complete. See the log for details.",
"Ui.Common.LocalDatabaseInitialisationFailed": "Self-hosted LiveSync cannot synchronise. Generate a report to review the detailed log.",
"Ui.Common.Signal.Caution": "CAUTION",
"Ui.Common.Signal.Danger": "DANGER",
"Ui.Common.Signal.Notice": "NOTICE",
"Ui.Common.Signal.Warning": "WARNING",
"Ui.Common.SomeFilesCouldNotBeSynchronised": "Not all files could be synchronised. Check the affected files. Generate a report to review the detailed log.",
"Ui.Settings.Advanced.LocalDatabaseTweak": "Local Database Tweak",
"Ui.Settings.Advanced.MemoryCache": "Memory Cache",
"Ui.Settings.Advanced.TransferTweak": "Transfer Tweak",
+2 -1
View File
@@ -2129,7 +2129,8 @@ xxhash64 (Fastest): xxhash64 (Fastest)
"This feature enables direct synchronisation between devices. No server is required, but both devices must be online at the same time for synchronisation to occur, and some features may be limited. Internet connection is only required to signalling (detecting peers) and not for data transfer.": "This feature enables direct synchronisation between devices. No server is required, but both devices must be online at the same time for synchronisation to occur, and some features may be limited. Internet connection is only required to signalling (detecting peers) and not for data transfer."
Ui:
Common:
LocalDatabaseInitialisationFailed: Local database initialisation did not complete. See the log for details.
LocalDatabaseInitialisationFailed: Self-hosted LiveSync cannot synchronise. Generate a report to review the detailed log.
SomeFilesCouldNotBeSynchronised: Not all files could be synchronised. Check the affected files. Generate a report to review the detailed log.
Signal:
Caution: CAUTION
Danger: DANGER
@@ -50,6 +50,7 @@ import {
MetadataDocumentRepairResults,
OfflineScanUnresolvedReasons,
repairMetadataDocumentIdentity,
VaultScanResults,
type MetadataDocumentIdentityIssue,
} from "@vrtmrz/livesync-commonlib/compat/serviceFeatures/offlineScanner";
import {
@@ -292,7 +293,8 @@ export function paneHatch(this: ObsidianLiveSyncSettingTab, paneEl: HTMLElement,
)) === repairAction,
repair: async (repairRequest) =>
await repairMetadataDocumentIdentity(this.core, repairRequest),
requestOrdinaryScan: async () => await this.services.vault.scanVault(true, false),
requestOrdinaryScan: async () =>
(await this.services.vault.scanVault(true, false)) === VaultScanResults.COMPLETED,
});
if (execution.status === MetadataIdentityRepairExecutions.CANCELLED) return;
+6 -2
View File
@@ -17,6 +17,7 @@ import type { InjectableServiceHub } from "@vrtmrz/livesync-commonlib/compat/ser
import type { LiveSyncCore } from "@/main.ts";
import { initialiseWorkerModule } from "@vrtmrz/livesync-commonlib/compat/worker/bgWorker";
import { manifestVersion, packageVersion } from "@vrtmrz/livesync-commonlib/compat/common/coreEnvVars";
import { VaultScanResults } from "@vrtmrz/livesync-commonlib/compat/serviceFeatures/offlineScanner";
export class ModuleLiveSyncMain extends AbstractModule {
async _onLiveSyncReady() {
@@ -44,12 +45,15 @@ export class ModuleLiveSyncMain extends AbstractModule {
}
// Ordinary start-up may continue when individual files could not be
// processed. Explicit Fetch and Rebuild flows retain the strict default.
const isInitialized = await this.services.databaseEvents.initialiseDatabase(false, false, false, true);
if (!isInitialized) {
const initialisationResult = await this.services.databaseEvents.initialiseDatabase(false, false, false, true);
if (initialisationResult === VaultScanResults.FAILED) {
this._log($msg("Ui.Common.LocalDatabaseInitialisationFailed"), LOG_LEVEL_NOTICE);
//TODO:stop all sync.
return false;
}
if (initialisationResult === VaultScanResults.COMPLETED_WITH_FILE_FAILURES) {
this._log($msg("Ui.Common.SomeFilesCouldNotBeSynchronised"), LOG_LEVEL_NOTICE);
}
if (!(await this.core.services.appLifecycle.onFirstInitialise())) return false;
// await this.core.$$realizeSettingSyncMode();
await this.services.control.applySettings();
@@ -47,4 +47,34 @@ describe("ModuleLiveSyncMain", () => {
expect(initialiseDatabase).toHaveBeenCalledWith(false, false, false, true);
expect(log).toHaveBeenCalledWith("Ui.Common.LocalDatabaseInitialisationFailed", LOG_LEVEL_NOTICE);
});
it("warns when start-up continues with individual file failures", async () => {
const initialiseDatabase = vi.fn(async () => "completed-with-file-failures");
const log = vi.fn();
const appLifecycle = {
onLayoutReady: vi.fn(async () => true),
onFirstInitialise: vi.fn(async () => true),
onScanningStartupIssues: vi.fn(async () => true),
};
const host = {
core: {
services: { appLifecycle },
},
services: {
appLifecycle,
control: { applySettings: vi.fn(async () => undefined) },
databaseEvents: { initialiseDatabase },
},
settings: {
suspendFileWatching: false,
suspendParseReplicationResult: false,
},
_log: log,
};
const result = await ModuleLiveSyncMain.prototype._onLiveSyncReady.call(host as never);
expect(result).toBe(true);
expect(log).toHaveBeenCalledWith("Ui.Common.SomeFilesCouldNotBeSynchronised", LOG_LEVEL_NOTICE);
});
});
+1 -1
View File
@@ -17,7 +17,7 @@ Earlier releases remain available in the 1.0 release history, the 1.0 preview hi
#### Fixed
- Conflict resolution dialogues now close when the same file is resolved elsewhere or the plug-in unloads. Requests for different files are shown one at a time, while a newer request for the same file replaces the stale dialogue.
- An individual file-processing failure during ordinary start-up no longer keeps the entire application unready. The affected path is recorded in verbose logs and remains eligible for retry, while explicit Fetch and Rebuild operations retain strict completion.
- An individual file-processing failure during ordinary start-up no longer keeps the entire application unready. A start-up notice asks the user to check the affected files and generate a report for details; each path is recorded in verbose logs and remains eligible for retry, while explicit Fetch and Rebuild operations retain strict completion.
- Replication readiness diagnostics now state that application initialisation is incomplete instead of reporting only 'Not ready'. Database-preparation failures show a short notice, with the failed stage available in verbose logs.
#### Improved