Compare commits

...

2 Commits

Author SHA1 Message Date
vorotamoroz
85e29b99b2 Bumped and documented. 2021-11-24 17:37:13 +09:00
vorotamoroz
2d223a1439 Add new configuration
- Use newer file if conflicted
I mprove:.
- status message improved.
- fixed misconfigurations on automatically disabled sync.
2021-11-24 17:31:03 +09:00
6 changed files with 36 additions and 12 deletions

View File

@@ -47,7 +47,7 @@ If you are an early adopter, maybe this value is left as 30 seconds. Please chan
### Manual Garbage Collect
Run "Garbage Collection" manually.
### End to End Encryption (beta)
### End to End Encryption
Encrypt your database. It affects only the database, your files are left as plain.
The encryption algorithm is AES-GCM.
@@ -119,6 +119,9 @@ If this option is enabled, move deleted files into the trash instead delete actu
### Do not delete empty folder
Self-hosted LiveSync will delete the folder when the folder becomes empty. If this option is enabled, leave it as an empty folder.
### Use newer file if conflicted (beta)
Always use the newer file to resolve and overwrite when conflict has occurred.
### minimum chunk size and LongLine threshold
The configuration of chunk splitting.

View File

@@ -49,7 +49,7 @@ Obsidianでのファイル操作が終わってから指定秒数が経過した
### Manual Garbage Collect
上記のGarbage Collectionを手動で行います。
### End to End Encryption (beta)
### End to End Encryption
データベースを暗号化します。この効果はデータベースに格納されるデータに限られ、ディスク上のファイルは平文のままです。
暗号化はAES-GCMを使用して行っています。
@@ -121,6 +121,9 @@ LiveSyncをONにするか、もしくはPeriodic Sync + Sync On File Openがオ
Self-hosted LiveSyncは通常、フォルダ内のファイルがすべて削除された場合、フォルダを削除します。
備考:Self-hosted LiveSyncの同期対象はファイルです。
### Use newer file if conflicted (beta)
競合が発生したとき、常に新しいファイルを使用して競合を自動的に解決します。
### minimum chunk size と LongLine threshold
チャンクの分割についての設定です。
Self-hosted LiveSyncは一つのチャンクのサイズを最低minimum chunk size文字確保した上で、できるだけ効率的に同期できるよう、ートを分割してチャンクを作成します。

30
main.ts
View File

@@ -1621,6 +1621,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
this.settings.liveSync = false;
this.settings.syncOnSave = false;
this.settings.syncOnStart = false;
this.settings.syncOnFileOpen = false;
this.settings.periodicReplication = false;
this.settings.versionUpFlash = "I changed specifications incompatiblly, so when you enable sync again, be sure to made version up all nother devides.";
this.saveSettings();
@@ -1850,6 +1851,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
// If batchsave is enabled, queue all changes and do nothing.
if (this.settings.batchSave) {
this.batchFileChange = Array.from(new Set([...this.batchFileChange, file.path]));
this.refreshStatusText();
return;
}
this.watchVaultChangeAsync(file, ...args);
@@ -1872,6 +1874,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
Logger(ex, LOG_LEVEL.VERBOSE);
}
});
this.refreshStatusText();
return Promise.all(promises);
}
batchFileChange: string[] = [];
@@ -2199,7 +2202,11 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
w = "?";
}
this.statusBar.title = this.localDatabase.syncStatus;
this.statusBar.setText(`Sync:${w}${sent}${arrived}`);
let waiting = "";
if (this.settings.batchSave) {
waiting = " " + this.batchFileChange.map((e) => "🚀").join("");
}
this.statusBar.setText(`Sync:${w}${sent}${arrived}${waiting}`);
}
async replicate(showMessage?: boolean) {
if (this.settings.versionUpFlash != "") {
@@ -2250,18 +2257,18 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
const count = objects.length;
Logger(procedurename);
let i = 0;
let lastTicks = performance.now() + 2000;
// let lastTicks = performance.now() + 2000;
let procs = objects.map(async (e) => {
try {
// debugger;
// Logger("hello?")
await callback(e);
i++;
if (lastTicks < performance.now()) {
if (i % 25 == 0) {
const notify = `${procedurename} : ${i}/${count}`;
if (notice != null) notice.setMessage(notify);
Logger(notify);
lastTicks = performance.now() + 2000;
// lastTicks = performance.now() + 2000;
// this.statusBar.setText(notify);
}
} catch (ex) {
@@ -2435,7 +2442,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
}
await this.localDatabase.deleteDBEntry(path, { rev: loser.rev });
await this.pullFile(path, null, true);
Logger(`automaticaly merged (newerFileResolve) :${path}`);
Logger(`Automaticaly merged (newerFileResolve) :${path}`, LOG_LEVEL.NOTICE);
return true;
}
// make diff.
@@ -2877,7 +2884,7 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
})
);
new Setting(containerEl)
.setName("End to End Encryption (beta)")
.setName("End to End Encryption")
.setDesc("Encrypting contents on the database.")
.addToggle((toggle) =>
toggle.setValue(this.plugin.settings.workingEncrypt).onChange(async (value) => {
@@ -2918,6 +2925,7 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
this.plugin.settings.periodicReplication = false;
this.plugin.settings.syncOnSave = false;
this.plugin.settings.syncOnStart = false;
this.plugin.settings.syncOnFileOpen = false;
this.plugin.settings.encrypt = this.plugin.settings.workingEncrypt;
this.plugin.settings.passphrase = this.plugin.settings.workingPassphrase;
@@ -3096,6 +3104,15 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
})
);
new Setting(containerEl)
.setName("Use newer file if conflicted (beta)")
.setDesc("Resolve conflicts by newer files automatically.")
.addToggle((toggle) =>
toggle.setValue(this.plugin.settings.resolveConflictsByNewerFile).onChange(async (value) => {
this.plugin.settings.resolveConflictsByNewerFile = value;
await this.plugin.saveSettings();
})
);
new Setting(containerEl)
.setName("Minimum chunk size")
.setDesc("(letters), minimum chunk size.")
@@ -3162,6 +3179,7 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
this.plugin.settings.periodicReplication = false;
this.plugin.settings.syncOnSave = false;
this.plugin.settings.syncOnStart = false;
this.plugin.settings.syncOnFileOpen = false;
await this.plugin.saveSettings();
applyDisplayEnabled();

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-livesync",
"name": "Self-hosted LiveSync",
"version": "0.1.17",
"version": "0.1.18",
"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",

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "obsidian-livesync",
"version": "0.1.16",
"version": "0.1.18",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "obsidian-livesync",
"version": "0.1.16",
"version": "0.1.18",
"license": "MIT",
"dependencies": {
"diff-match-patch": "^1.0.5",

View File

@@ -1,6 +1,6 @@
{
"name": "obsidian-livesync",
"version": "0.1.16",
"version": "0.1.18",
"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",
"scripts": {