Add new feature:

- Reread all files
This commit is contained in:
vorotamoroz
2021-12-06 12:19:05 +09:00
parent 0ee73860d1
commit 2b11be05ec
3 changed files with 42 additions and 2 deletions

View File

@@ -165,6 +165,9 @@ The remote database indicates that has been unlocked Pattern 1.
When you mark all devices as resolved, you can unlock the database. When you mark all devices as resolved, you can unlock the database.
But, there's no problem even if you leave it as it is. But, there's no problem even if you leave it as it is.
### Reread all files
Reread all files in the vault, and update them into the database if there's diff or could not read from the database.
### Drop history ### Drop history
Drop all histories on the local database and the remote database, and initialize When synchronization time has been prolonged to the new device or new vault, or database size became to be much larger. Try this. Drop all histories on the local database and the remote database, and initialize When synchronization time has been prolonged to the new device or new vault, or database size became to be much larger. Try this.

View File

@@ -166,6 +166,9 @@ Self-hosted LiveSyncは一つのチャンクのサイズを最低minimum chunk s
ご使用のすべてのデバイスでロックを解除した場合は、データベースのロックを解除することができます。 ご使用のすべてのデバイスでロックを解除した場合は、データベースのロックを解除することができます。
ただし、このまま放置しても問題はありません。 ただし、このまま放置しても問題はありません。
### Reread all files
Vault内のファイルを全て読み込み直し、もし差分があったり、データベースから正常に読み込めなかったものに関して、データベースに反映します。
### Drop history ### Drop history
データベースに記録されている履歴を削除し、データベースを初期化します。 データベースに記録されている履歴を削除し、データベースを初期化します。
新しい端末や新しいVaultへの同期にやたらと時間がかかったり、データベースサイズが肥大化したりしてきた際に使用してください。 新しい端末や新しいVaultへの同期にやたらと時間がかかったり、データベースサイズが肥大化したりしてきた際に使用してください。

38
main.ts
View File

@@ -2062,8 +2062,13 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
this.notifies[messagecontent].count++; this.notifies[messagecontent].count++;
this.notifies[messagecontent].notice.setMessage(`(${this.notifies[messagecontent].count}):${messagecontent}`); this.notifies[messagecontent].notice.setMessage(`(${this.notifies[messagecontent].count}):${messagecontent}`);
this.notifies[messagecontent].timer = setTimeout(() => { this.notifies[messagecontent].timer = setTimeout(() => {
this.notifies[messagecontent].notice.hide(); const notify = this.notifies[messagecontent].notice;
delete this.notifies[messagecontent]; delete this.notifies[messagecontent];
try {
notify.hide();
} catch (ex) {
// NO OP
}
}, 5000); }, 5000);
} else { } else {
let notify = new Notice(messagecontent, 0); let notify = new Notice(messagecontent, 0);
@@ -2071,8 +2076,8 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
count: 0, count: 0,
notice: notify, notice: notify,
timer: setTimeout(() => { timer: setTimeout(() => {
notify.hide();
delete this.notifies[messagecontent]; delete this.notifies[messagecontent];
notify.hide();
}, 5000), }, 5000),
}; };
} }
@@ -3351,6 +3356,35 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
await this.plugin.replicate(true); await this.plugin.replicate(true);
} }
}; };
new Setting(containerEl)
.setName("Reread all files")
.setDesc("Reread all files and update the database without dropping history")
.addButton((button) =>
button
.setButtonText("Reread")
.setDisabled(false)
.setWarning()
.onClick(async () => {
const files = this.app.vault.getFiles();
Logger("Reread all files started", LOG_LEVEL.NOTICE);
let notice = new Notice("", 0);
let i = 0;
for (const file of files) {
i++;
Logger(`Update into ${file.path}`);
notice.setMessage(`${i}/${files.length}\n${file.path}`);
try {
await this.plugin.updateIntoDB(file);
} catch (ex) {
Logger("could not update:");
Logger(ex);
}
}
notice.hide();
Logger("done", LOG_LEVEL.NOTICE);
})
);
new Setting(containerEl) new Setting(containerEl)
.setName("Drop History") .setName("Drop History")
.setDesc("Initialize local and remote database, and send all or retrieve all again.") .setDesc("Initialize local and remote database, and send all or retrieve all again.")