diff --git a/src/CmdSetupLiveSync.ts b/src/CmdSetupLiveSync.ts index 354d48b..e8105fd 100644 --- a/src/CmdSetupLiveSync.ts +++ b/src/CmdSetupLiveSync.ts @@ -1,4 +1,4 @@ -import { type EntryDoc, type ObsidianLiveSyncSettings, DEFAULT_SETTINGS, LOG_LEVEL_NOTICE, REMOTE_COUCHDB, REMOTE_MINIO } from "./lib/src/types"; +import { type EntryDoc, type ObsidianLiveSyncSettings, DEFAULT_SETTINGS, LOG_LEVEL_NOTICE, REMOTE_COUCHDB } from "./lib/src/types"; import { configURIBase } from "./types"; import { Logger } from "./lib/src/logger"; import { PouchDB } from "./lib/src/pouchdb-browser.js"; @@ -312,7 +312,7 @@ Of course, we are able to disable these features.` } async suspendReflectingDatabase() { if (this.plugin.settings.doNotSuspendOnFetching) return; - if (this.plugin.settings.remoteType == REMOTE_MINIO) return; + // if (this.plugin.settings.remoteType == REMOTE_MINIO) return; Logger(`Suspending reflection: Database and storage changes will not be reflected in each other until completely finished the fetching.`, LOG_LEVEL_NOTICE); this.plugin.settings.suspendParseReplicationResult = true; this.plugin.settings.suspendFileWatching = true; @@ -320,7 +320,7 @@ Of course, we are able to disable these features.` } async resumeReflectingDatabase() { if (this.plugin.settings.doNotSuspendOnFetching) return; - if (this.plugin.settings.remoteType == REMOTE_MINIO) return; + // if (this.plugin.settings.remoteType == REMOTE_MINIO) return; Logger(`Database and storage reflection has been resumed!`, LOG_LEVEL_NOTICE); this.plugin.settings.suspendParseReplicationResult = false; this.plugin.settings.suspendFileWatching = false; diff --git a/src/ObsidianLiveSyncSettingTab.ts b/src/ObsidianLiveSyncSettingTab.ts index 8e6bd42..56f5593 100644 --- a/src/ObsidianLiveSyncSettingTab.ts +++ b/src/ObsidianLiveSyncSettingTab.ts @@ -2321,6 +2321,61 @@ ${stringifyYaml(pluginConfig)}`; }) ) + if (this.plugin.settings.remoteType != REMOTE_COUCHDB) { + new Setting(containerMaintenanceEl) + .setName("Reset journal received history") + .setDesc("Initialise journal received history. On the next sync, every item except this device sent will be downloaded again.") + .addButton((button) => + button + .setButtonText("Reset received") + .setWarning() + .setDisabled(false) + .onClick(async () => { + await this.plugin.getMinioJournalSyncClient().updateCheckPointInfo((info) => ({ ...info, receivedFiles: [], knownIDs: [] })); + Logger(`Journal received history has been cleared.`, LOG_LEVEL_NOTICE); + }) + ) + new Setting(containerMaintenanceEl) + .setName("Reset journal sent history") + .setDesc("Initialise journal sent history. On the next sync, every item except this device received will be sent again.") + .addButton((button) => + button + .setButtonText("Reset sent history") + .setWarning() + .setDisabled(false) + .onClick(async () => { + await this.plugin.getMinioJournalSyncClient().updateCheckPointInfo((info) => ({ ...info, lastLocalSeq: 0, sentIDs: [], sentFiles: [] })); + Logger(`Journal sent history has been cleared.`, LOG_LEVEL_NOTICE); + }) + ) + new Setting(containerMaintenanceEl) + .setName("Reset all journal counter") + .setDesc("Initialise all journal history, On the next sync, every item will be received and sent.") + .addButton((button) => + button + .setButtonText("Reset all") + .setWarning() + .setDisabled(false) + .onClick(async () => { + await this.plugin.getMinioJournalSyncClient().updateCheckPointInfo((info) => ({ ...info, receivedFiles: [], knownIDs: [], lastLocalSeq: 0, sentIDs: [], sentFiles: [] })); + Logger(`Journal exchange history has been cleared.`, LOG_LEVEL_NOTICE); + }) + ) + new Setting(containerMaintenanceEl) + .setName("Make empty the bucket") + .setDesc("Delete all data on the remote.") + .addButton((button) => + button + .setButtonText("Delete") + .setWarning() + .setDisabled(false) + .onClick(async () => { + await this.plugin.getMinioJournalSyncClient().updateCheckPointInfo((info) => ({ ...info, receivedFiles: [], knownIDs: [], lastLocalSeq: 0, sentIDs: [], sentFiles: [] })); + await this.plugin.resetRemoteBucket(); + Logger(`the bucket has been cleared.`, LOG_LEVEL_NOTICE); + }) + ) + } containerMaintenanceEl.createEl("h4", { text: "Local database" }); diff --git a/src/lib b/src/lib index 5da1dbc..0d1ed24 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 5da1dbc7fc83d0b9a82fcc60228d4394874c5be8 +Subproject commit 0d1ed24e31f754515a698b170d24b46dca8caaf5 diff --git a/src/main.ts b/src/main.ts index e4e2e90..9728b46 100644 --- a/src/main.ts +++ b/src/main.ts @@ -682,63 +682,6 @@ Note: We can always able to read V1 format. It will be progressively converted. this.addOnConfigSync.showPluginSyncModal(); }).addClass("livesync-ribbon-showcustom"); - this.addCommand({ - id: "debug-x1", - name: "Journal send", - callback: () => { - this.journalSendTest(); - } - }); - this.addCommand({ - id: "debug-x3", - name: "Journal receive", - callback: () => { - this.journalFetchTest(); - } - }); - this.addCommand({ - id: "debug-x4", - name: "Sync By Journal", - callback: () => { - this.journalSyncTest(); - } - }); - this.addCommand({ - id: "debug-x5", - name: "Reset journal sync", - callback: () => { - this.resetJournalSync(); - } - }); - this.addCommand({ - id: "debug-x6", - name: "Reset journal sync and delete all items on the bucket", - callback: () => { - this.resetRemoteBucket(); - } - }) - this.addCommand({ - id: "debug-x7", - name: "Perform Test", - callback: () => { - // const p = getMockedPouch(); - // this.localDatabase.localDatabase.replicate.to(p, { since: 1000, checkpoint: "source" }); - } - }) - this.addCommand({ - id: "debug-x8", - name: "Pack test", - callback: async () => { - const minioJournal = this.getMinioJournalSyncClient(); - // const pack = await minioJournal.createJournalPack(); - // console.warn(); - console.warn(await minioJournal._createJournalPack()); - } - }) - - - - this.addCommand({ id: "view-log", name: "Show log",