diff --git a/src/CmdSetupLiveSync.ts b/src/CmdSetupLiveSync.ts index d6bc7e5..c8964cd 100644 --- a/src/CmdSetupLiveSync.ts +++ b/src/CmdSetupLiveSync.ts @@ -134,7 +134,7 @@ export class SetupLiveSync extends LiveSyncCommands { } else if (setupType == setupAsMerge) { this.plugin.settings = newSettingW; this.plugin.usedPassphrase = ""; - await this.fetchLocalWithKeepLocal(); + await this.fetchLocalWithRebuild(); } else if (setupType == setupAgain) { const confirm = "I know this operation will rebuild all my databases with files on this device, and files that are on the remote database and I didn't synchronize to any other devices will be lost and want to proceed indeed."; if (await askSelectString(this.app, "Do you really want to do this?", ["Cancel", confirm]) != confirm) { @@ -377,11 +377,13 @@ Of course, we are able to disable these features.` await this.plugin.replicateAllFromServer(true); await delay(1000); await this.plugin.replicateAllFromServer(true); - await this.fetchRemoteChunks(); + // if (!tryLessFetching) { + // await this.fetchRemoteChunks(); + // } await this.resumeReflectingDatabase(); await this.askHiddenFileConfiguration({ enableFetch: true }); } - async fetchLocalWithKeepLocal() { + async fetchLocalWithRebuild() { return await this.fetchLocal(true); } async rebuildRemote() { diff --git a/src/ObsidianLiveSyncSettingTab.ts b/src/ObsidianLiveSyncSettingTab.ts index c52480d..f2a00df 100644 --- a/src/ObsidianLiveSyncSettingTab.ts +++ b/src/ObsidianLiveSyncSettingTab.ts @@ -1,5 +1,5 @@ import { App, PluginSettingTab, Setting, sanitizeHTMLToDom, TextAreaComponent, MarkdownRenderer, stringifyYaml } from "./deps"; -import { DEFAULT_SETTINGS, type ObsidianLiveSyncSettings, type ConfigPassphraseStore, type RemoteDBSettings, type FilePathWithPrefix, type HashAlgorithm, type DocumentID, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE, LOG_LEVEL_INFO, type LoadedEntry } from "./lib/src/types"; +import { DEFAULT_SETTINGS, type ObsidianLiveSyncSettings, type ConfigPassphraseStore, type RemoteDBSettings, type FilePathWithPrefix, type HashAlgorithm, type DocumentID, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE, LOG_LEVEL_INFO, type LoadedEntry, PREFERRED_SETTING_CLOUDANT, PREFERRED_SETTING_SELF_HOSTED } from "./lib/src/types"; import { createBinaryBlob, createTextBlob, delay, isDocContentSame } from "./lib/src/utils"; import { decodeBinary, versionNumberString2Number } from "./lib/src/strbin"; import { Logger } from "./lib/src/logger"; @@ -664,7 +664,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { .setWarning() .setDisabled(false) .onClick(async () => { - await rebuildDB("localOnlyWithChunks"); + await rebuildDB("localOnly"); }) ) .addButton((button) => @@ -774,9 +774,10 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { this.plugin.settings.passphrase = ""; } if (isCloudantURI(this.plugin.settings.couchDB_URI)) { - this.plugin.settings.customChunkSize = 0; + // this.plugin.settings.customChunkSize = 0; + this.plugin.settings = { ...this.plugin.settings, ...PREFERRED_SETTING_CLOUDANT }; } else { - this.plugin.settings.customChunkSize = 50; + this.plugin.settings = { ...this.plugin.settings, ...PREFERRED_SETTING_SELF_HOSTED }; } changeDisplay("30") }) @@ -1054,7 +1055,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab { if (!this.plugin.settings.isConfigured) { this.plugin.settings.isConfigured = true; await this.plugin.saveSettings(); - await rebuildDB("localOnlyWithChunks"); + await rebuildDB("localOnly"); Logger("All done! Please set up subsequent devices with 'Copy current settings as a new setup URI' and 'Use the copied setup URI'.", LOG_LEVEL_NOTICE); await this.plugin.addOnSetup.command_copySetupURI(); } else { @@ -1966,7 +1967,7 @@ ${stringifyYaml(pluginConfig)}`; toggle.setValue(!this.plugin.settings.useIndexedDBAdapter).onChange(async (value) => { this.plugin.settings.useIndexedDBAdapter = !value; await this.plugin.saveSettings(); - await rebuildDB("localOnlyWithChunks"); + await rebuildDB("localOnly"); }) ); @@ -2164,20 +2165,20 @@ ${stringifyYaml(pluginConfig)}`; .setWarning() .setDisabled(false) .onClick(async () => { - await rebuildDB("localOnlyWithChunks"); + await rebuildDB("localOnly"); }) ) new Setting(containerMaintenanceEl) - .setName("Fetch rebuilt DB with all remote chunks") - .setDesc("Restore or reconstruct local database from remote database but use remote chunk .") + .setName("Fetch rebuilt DB (Save local documents before)") + .setDesc("Restore or reconstruct local database from remote database but use local chunks.") .addButton((button) => button - .setButtonText("Fetch all") + .setButtonText("Save and Fetch") .setWarning() .setDisabled(false) .onClick(async () => { - await rebuildDB("localOnly"); + await rebuildDB("localOnlyWithChunks"); }) ) diff --git a/src/lib b/src/lib index 5269544..b9b7053 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 5269544598bbd110b83a518fa550be263155b666 +Subproject commit b9b70535edaf2af5d5c8d3f69d4f6747c6b4b179 diff --git a/src/main.ts b/src/main.ts index 4636949..09d508f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1631,7 +1631,7 @@ We can perform a command in this file. } databaseQueueCount = reactiveSource(0); - databaseQueuedProcessor = new KeyedQueueProcessor(async (docs: EntryBody[]) => { + databaseQueuedProcessor = new QueueProcessor(async (docs: EntryBody[]) => { const dbDoc = docs[0]; const path = this.getPath(dbDoc); // If `Read chunks online` is disabled, chunks should be transferred before here. @@ -1708,7 +1708,7 @@ We can perform a command in this file. Logger(`Processing ${change.path} has been skipped due to file size exceeding the limit`, LOG_LEVEL_NOTICE); return; } - this.databaseQueuedProcessor.enqueueWithKey(change.path, change); + this.databaseQueuedProcessor.enqueue(change); } return; }, { batchSize: 1, suspended: true, concurrentLimit: 100, delay: 0, totalRemainingReactiveSource: this.replicationResultCount }).startPipeline().onUpdateProgress(() => { @@ -1902,7 +1902,7 @@ Even if you choose to clean up, you will see this option again if you exit Obsid const CHOICE_DISMISS = "Dismiss"; const ret = await confirmWithMessage(this, "Cleaned", message, [CHOICE_FETCH, CHOICE_CLEAN, CHOICE_DISMISS], CHOICE_DISMISS, 30); if (ret == CHOICE_FETCH) { - await performRebuildDB(this, "localOnlyWithChunks"); + await performRebuildDB(this, "localOnly"); } if (ret == CHOICE_CLEAN) { const remoteDB = await this.getReplicator().connectRemoteCouchDBWithSetting(this.settings, this.getIsMobile(), true); @@ -1936,7 +1936,7 @@ Or if you are sure know what had been happened, we can unlock the database from const CHOICE_DISMISS = "Dismiss"; const ret = await confirmWithMessage(this, "Locked", message, [CHOICE_FETCH, CHOICE_DISMISS], CHOICE_DISMISS, 10); if (ret == CHOICE_FETCH) { - await performRebuildDB(this, "localOnlyWithChunks"); + await performRebuildDB(this, "localOnly"); } } }