diff --git a/manifest.json b/manifest.json index 89986a0..5c0b1a5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-livesync", "name": "Self-hosted LiveSync", - "version": "0.11.2", + "version": "0.11.3", "minAppVersion": "0.9.12", "description": "Community implementation of self-hosted livesync. Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "author": "vorotamoroz", diff --git a/package-lock.json b/package-lock.json index 51a8ca7..b6d575a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-livesync", - "version": "0.11.2", + "version": "0.11.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "obsidian-livesync", - "version": "0.11.2", + "version": "0.11.3", "license": "MIT", "dependencies": { "diff-match-patch": "^1.0.5", diff --git a/package.json b/package.json index 77f97c7..49806a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-livesync", - "version": "0.11.2", + "version": "0.11.3", "description": "Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "main": "main.js", "type": "module", @@ -37,7 +37,7 @@ "diff-match-patch": "^1.0.5", "esbuild": "0.13.12", "esbuild-svelte": "^0.6.0", - "idb": "^7.0.1", + "idb": "^7.0.1", "svelte-preprocess": "^4.10.2", "xxhash-wasm": "^0.4.2" } diff --git a/src/ObsidianLiveSyncSettingTab.ts b/src/ObsidianLiveSyncSettingTab.ts index f2f9c4a..b78cd86 100644 --- a/src/ObsidianLiveSyncSettingTab.ts +++ b/src/ObsidianLiveSyncSettingTab.ts @@ -710,15 +710,15 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { }) ); - new Setting(containerSyncSettingEl) - .setName("Skip old files on sync") - .setDesc("Skip old incoming if incoming changes older than storage.") - .addToggle((toggle) => - toggle.setValue(this.plugin.settings.skipOlderFilesOnSync).onChange(async (value) => { - this.plugin.settings.skipOlderFilesOnSync = value; - await this.plugin.saveSettings(); - }) - ); + // new Setting(containerSyncSettingEl) + // .setName("Skip old files on sync") + // .setDesc("Skip old incoming if incoming changes older than storage.") + // .addToggle((toggle) => + // toggle.setValue(this.plugin.settings.skipOlderFilesOnSync).onChange(async (value) => { + // this.plugin.settings.skipOlderFilesOnSync = value; + // await this.plugin.saveSettings(); + // }) + // ); new Setting(containerSyncSettingEl) .setName("Check conflict only on opening file.") .setDesc("Do not check conflict while replication") diff --git a/src/main.ts b/src/main.ts index 1418a6b..97c92b2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -961,7 +961,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin { } } async procQueuedFiles() { - await runWithLock("procQueue", true, async () => { + await runWithLock("procQueue", false, async () => { this.saveQueuedFiles(); for (const queue of this.queuedFiles) { if (queue.done) continue; @@ -972,8 +972,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin { Logger(`Applying ${queue.entry._id} (${queue.entry._rev}) change...`); await this.handleDBChanged(queue.entry); } - } - if (now > queue.timeout) { + } else if (now > queue.timeout) { if (!queue.warned) Logger(`Timed out: ${queue.entry._id} could not collect ${queue.missingChildren.length} chunks. plugin keeps watching, but you have to check the file after the replication.`, LOG_LEVEL.NOTICE); queue.warned = true; continue; @@ -1005,13 +1004,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin { if (isNewFileCompleted) this.procQueuedFiles(); } async parseIncomingDoc(doc: PouchDB.Core.ExistingDocument) { - const skipOldFile = this.settings.skipOlderFilesOnSync; + const skipOldFile = this.settings.skipOlderFilesOnSync && false; //patched temporary. if (skipOldFile) { const info = this.app.vault.getAbstractFileByPath(id2path(doc._id)); if (info && info instanceof TFile) { const localMtime = ~~((info as TFile).stat.mtime / 1000); const docMtime = ~~(doc.mtime / 1000); + //TODO: some margin required. if (localMtime >= docMtime) { Logger(`${doc._id} Skipped, older than storage.`, LOG_LEVEL.VERBOSE); return; @@ -1027,15 +1027,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin { if ("children" in doc) { const c = await this.localDatabase.localDatabase.allDocs({ keys: doc.children, include_docs: false }); const missing = c.rows.filter((e) => "error" in e).map((e) => e.key); - if (missing.length) Logger(`${doc._id}(${doc._rev}) Queued (waiting ${missing.length} items)`, LOG_LEVEL.VERBOSE); + Logger(`${doc._id}(${doc._rev}) Queued (waiting ${missing.length} items)`, LOG_LEVEL.VERBOSE); newQueue.missingChildren = missing; this.queuedFiles.push(newQueue); - this.saveQueuedFiles(); } else { this.queuedFiles.push(newQueue); - this.saveQueuedFiles(); - this.procQueuedFiles(); } + this.saveQueuedFiles(); + this.procQueuedFiles(); } periodicSyncHandler: number = null; @@ -1328,6 +1327,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin { }); await allSettledWithConcurrencyLimit(procs, 10); + Logger(`${procedurename} done.`); }; await runAll("UPDATE DATABASE", onlyInStorage, async (e) => { Logger(`Update into ${e.path}`);