diff --git a/manifest.json b/manifest.json index f54184e..57b88bd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-livesync", "name": "Self-hosted LiveSync", - "version": "0.24.27", + "version": "0.24.28", "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 152157b..2187014 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-livesync", - "version": "0.24.26", + "version": "0.24.28", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "obsidian-livesync", - "version": "0.24.26", + "version": "0.24.28", "license": "MIT", "dependencies": { "@aws-sdk/client-s3": "^3.808.0", diff --git a/package.json b/package.json index eac8d6d..3c42456 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-livesync", - "version": "0.24.27", + "version": "0.24.28", "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", diff --git a/src/lib b/src/lib index 68434ac..3f3cf7d 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 68434acfdd527fe715a21153aef5ea777cec4cf9 +Subproject commit 3f3cf7d61da21372428f2b5f62bb839fad1a2928 diff --git a/src/modules/core/ModuleReplicator.ts b/src/modules/core/ModuleReplicator.ts index 9c19ab3..944e7a8 100644 --- a/src/modules/core/ModuleReplicator.ts +++ b/src/modules/core/ModuleReplicator.ts @@ -244,34 +244,49 @@ Even if you choose to clean up, you will see this option again if you exit Obsid async loadQueuedFiles() { if (this.settings.suspendParseReplicationResult) return; if (!this.settings.isConfigured) return; - const kvDBKey = "queued-files"; - // const ids = [...new Set(JSON.parse(localStorage.getItem(lsKey) || "[]"))] as string[]; - const ids = [...new Set((await this.core.kvDB.get(kvDBKey)) ?? [])]; - const batchSize = 100; - const chunkedIds = arrayToChunkedArray(ids, batchSize); + try { + const kvDBKey = "queued-files"; + // const ids = [...new Set(JSON.parse(localStorage.getItem(lsKey) || "[]"))] as string[]; + const ids = [...new Set((await this.core.kvDB.get(kvDBKey)) ?? [])]; + const batchSize = 100; + const chunkedIds = arrayToChunkedArray(ids, batchSize); - // suspendParseReplicationResult is true, so we have to resume it if it is suspended. - if (this.replicationResultProcessor.isSuspended) { - this.replicationResultProcessor.resume(); - } - for await (const idsBatch of chunkedIds) { - const ret = await this.localDatabase.allDocsRaw({ - keys: idsBatch, - include_docs: true, - limit: 100, - }); - const docs = ret.rows.filter((e) => e.doc).map((e) => e.doc) as PouchDB.Core.ExistingDocument[]; - const errors = ret.rows.filter((e) => !e.doc && !e.value.deleted); - if (errors.length > 0) { - Logger("Some queued processes were not resurrected"); - Logger(JSON.stringify(errors), LOG_LEVEL_VERBOSE); + // suspendParseReplicationResult is true, so we have to resume it if it is suspended. + if (this.replicationResultProcessor.isSuspended) { + this.replicationResultProcessor.resume(); + } + for await (const idsBatch of chunkedIds) { + const ret = await this.localDatabase.allDocsRaw({ + keys: idsBatch, + include_docs: true, + limit: 100, + }); + const docs = ret.rows + .filter((e) => e.doc) + .map((e) => e.doc) as PouchDB.Core.ExistingDocument[]; + const errors = ret.rows.filter((e) => !e.doc && !e.value.deleted); + if (errors.length > 0) { + Logger("Some queued processes were not resurrected"); + Logger(JSON.stringify(errors), LOG_LEVEL_VERBOSE); + } + this.replicationResultProcessor.enqueueAll(docs); + } + } catch (e) { + Logger(`Failed to load queued files.`, LOG_LEVEL_NOTICE); + Logger(e, LOG_LEVEL_VERBOSE); + } finally { + // Check again before awaiting, + if (this.replicationResultProcessor.isSuspended) { + this.replicationResultProcessor.resume(); } - this.replicationResultProcessor.enqueueAll(docs); } - if (this.replicationResultProcessor.isSuspended) { - this.replicationResultProcessor.resume(); + // Wait for all queued files to be processed. + try { + await this.replicationResultProcessor.waitForAllProcessed(); + } catch (e) { + Logger(`Failed to wait for all queued files to be processed.`, LOG_LEVEL_NOTICE); + Logger(e, LOG_LEVEL_VERBOSE); } - await this.replicationResultProcessor.waitForAllProcessed(); } replicationResultProcessor = new QueueProcessor( diff --git a/src/modules/features/SettingDialogue/ObsidianLiveSyncSettingTab.ts b/src/modules/features/SettingDialogue/ObsidianLiveSyncSettingTab.ts index 1f2d4d5..78d21b7 100644 --- a/src/modules/features/SettingDialogue/ObsidianLiveSyncSettingTab.ts +++ b/src/modules/features/SettingDialogue/ObsidianLiveSyncSettingTab.ts @@ -2090,7 +2090,12 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal .autoWireToggle("syncAfterMerge", { onUpdate: onlyOnNonLiveSync }); }); - void addPanel(paneEl, $msg("obsidianLiveSyncSettingTab.titleUpdateThinning")).then((paneEl) => { + void addPanel( + paneEl, + $msg("obsidianLiveSyncSettingTab.titleUpdateThinning"), + undefined, + visibleOnly(() => !this.isConfiguredAs("syncMode", "LIVESYNC")) + ).then((paneEl) => { paneEl.addClass("wizardHidden"); new Setting(paneEl).setClass("wizardHidden").autoWireToggle("batchSave"); new Setting(paneEl).setClass("wizardHidden").autoWireNumeric("batchSaveMinimumDelay", { diff --git a/updates.md b/updates.md index 4a4ee81..bfe6b38 100644 --- a/updates.md +++ b/updates.md @@ -1,3 +1,12 @@ +## 0.24.28 + +### Fixed + +- Batch Update is no longer available in LiveSync mode to avoid unexpected behaviour. (#653) +- Now compatible with Cloudflare R2 again for bucket synchronisation. + - @edo-bari-ikutsu, thank you for [your contribution](https://github.com/vrtmrz/livesync-commonlib/pull/12)! +- Prevention of broken behaviour due to database connection failures added (#649). + ## 0.24.27 ### Improved