mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-20 13:11:29 +00:00
Fixed:
- Fixed ignoring changes on replicating. - Disabled `Skip old files on sync` temporary (so fragile between multiple devices)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-livesync",
|
"id": "obsidian-livesync",
|
||||||
"name": "Self-hosted LiveSync",
|
"name": "Self-hosted LiveSync",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"minAppVersion": "0.9.12",
|
"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.",
|
"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",
|
"author": "vorotamoroz",
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian-livesync",
|
"name": "obsidian-livesync",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "obsidian-livesync",
|
"name": "obsidian-livesync",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"diff-match-patch": "^1.0.5",
|
"diff-match-patch": "^1.0.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian-livesync",
|
"name": "obsidian-livesync",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"description": "Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.",
|
"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",
|
"main": "main.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -710,15 +710,15 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
new Setting(containerSyncSettingEl)
|
// new Setting(containerSyncSettingEl)
|
||||||
.setName("Skip old files on sync")
|
// .setName("Skip old files on sync")
|
||||||
.setDesc("Skip old incoming if incoming changes older than storage.")
|
// .setDesc("Skip old incoming if incoming changes older than storage.")
|
||||||
.addToggle((toggle) =>
|
// .addToggle((toggle) =>
|
||||||
toggle.setValue(this.plugin.settings.skipOlderFilesOnSync).onChange(async (value) => {
|
// toggle.setValue(this.plugin.settings.skipOlderFilesOnSync).onChange(async (value) => {
|
||||||
this.plugin.settings.skipOlderFilesOnSync = value;
|
// this.plugin.settings.skipOlderFilesOnSync = value;
|
||||||
await this.plugin.saveSettings();
|
// await this.plugin.saveSettings();
|
||||||
})
|
// })
|
||||||
);
|
// );
|
||||||
new Setting(containerSyncSettingEl)
|
new Setting(containerSyncSettingEl)
|
||||||
.setName("Check conflict only on opening file.")
|
.setName("Check conflict only on opening file.")
|
||||||
.setDesc("Do not check conflict while replication")
|
.setDesc("Do not check conflict while replication")
|
||||||
|
|||||||
14
src/main.ts
14
src/main.ts
@@ -961,7 +961,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async procQueuedFiles() {
|
async procQueuedFiles() {
|
||||||
await runWithLock("procQueue", true, async () => {
|
await runWithLock("procQueue", false, async () => {
|
||||||
this.saveQueuedFiles();
|
this.saveQueuedFiles();
|
||||||
for (const queue of this.queuedFiles) {
|
for (const queue of this.queuedFiles) {
|
||||||
if (queue.done) continue;
|
if (queue.done) continue;
|
||||||
@@ -972,8 +972,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
Logger(`Applying ${queue.entry._id} (${queue.entry._rev}) change...`);
|
Logger(`Applying ${queue.entry._id} (${queue.entry._rev}) change...`);
|
||||||
await this.handleDBChanged(queue.entry);
|
await this.handleDBChanged(queue.entry);
|
||||||
}
|
}
|
||||||
}
|
} else if (now > queue.timeout) {
|
||||||
if (now > queue.timeout) {
|
|
||||||
if (!queue.warned) Logger(`Timed out: ${queue.entry._id} could not collect ${queue.missingChildren.length} chunks. plugin keeps watching, but you have to check the file after the replication.`, LOG_LEVEL.NOTICE);
|
if (!queue.warned) Logger(`Timed out: ${queue.entry._id} could not collect ${queue.missingChildren.length} chunks. plugin keeps watching, but you have to check the file after the replication.`, LOG_LEVEL.NOTICE);
|
||||||
queue.warned = true;
|
queue.warned = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -1005,13 +1004,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
if (isNewFileCompleted) this.procQueuedFiles();
|
if (isNewFileCompleted) this.procQueuedFiles();
|
||||||
}
|
}
|
||||||
async parseIncomingDoc(doc: PouchDB.Core.ExistingDocument<EntryBody>) {
|
async parseIncomingDoc(doc: PouchDB.Core.ExistingDocument<EntryBody>) {
|
||||||
const skipOldFile = this.settings.skipOlderFilesOnSync;
|
const skipOldFile = this.settings.skipOlderFilesOnSync && false; //patched temporary.
|
||||||
if (skipOldFile) {
|
if (skipOldFile) {
|
||||||
const info = this.app.vault.getAbstractFileByPath(id2path(doc._id));
|
const info = this.app.vault.getAbstractFileByPath(id2path(doc._id));
|
||||||
|
|
||||||
if (info && info instanceof TFile) {
|
if (info && info instanceof TFile) {
|
||||||
const localMtime = ~~((info as TFile).stat.mtime / 1000);
|
const localMtime = ~~((info as TFile).stat.mtime / 1000);
|
||||||
const docMtime = ~~(doc.mtime / 1000);
|
const docMtime = ~~(doc.mtime / 1000);
|
||||||
|
//TODO: some margin required.
|
||||||
if (localMtime >= docMtime) {
|
if (localMtime >= docMtime) {
|
||||||
Logger(`${doc._id} Skipped, older than storage.`, LOG_LEVEL.VERBOSE);
|
Logger(`${doc._id} Skipped, older than storage.`, LOG_LEVEL.VERBOSE);
|
||||||
return;
|
return;
|
||||||
@@ -1027,16 +1027,15 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
if ("children" in doc) {
|
if ("children" in doc) {
|
||||||
const c = await this.localDatabase.localDatabase.allDocs({ keys: doc.children, include_docs: false });
|
const c = await this.localDatabase.localDatabase.allDocs({ keys: doc.children, include_docs: false });
|
||||||
const missing = c.rows.filter((e) => "error" in e).map((e) => e.key);
|
const missing = c.rows.filter((e) => "error" in e).map((e) => e.key);
|
||||||
if (missing.length) Logger(`${doc._id}(${doc._rev}) Queued (waiting ${missing.length} items)`, LOG_LEVEL.VERBOSE);
|
Logger(`${doc._id}(${doc._rev}) Queued (waiting ${missing.length} items)`, LOG_LEVEL.VERBOSE);
|
||||||
newQueue.missingChildren = missing;
|
newQueue.missingChildren = missing;
|
||||||
this.queuedFiles.push(newQueue);
|
this.queuedFiles.push(newQueue);
|
||||||
this.saveQueuedFiles();
|
|
||||||
} else {
|
} else {
|
||||||
this.queuedFiles.push(newQueue);
|
this.queuedFiles.push(newQueue);
|
||||||
|
}
|
||||||
this.saveQueuedFiles();
|
this.saveQueuedFiles();
|
||||||
this.procQueuedFiles();
|
this.procQueuedFiles();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
periodicSyncHandler: number = null;
|
periodicSyncHandler: number = null;
|
||||||
|
|
||||||
//---> Sync
|
//---> Sync
|
||||||
@@ -1328,6 +1327,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await allSettledWithConcurrencyLimit(procs, 10);
|
await allSettledWithConcurrencyLimit(procs, 10);
|
||||||
|
Logger(`${procedurename} done.`);
|
||||||
};
|
};
|
||||||
await runAll("UPDATE DATABASE", onlyInStorage, async (e) => {
|
await runAll("UPDATE DATABASE", onlyInStorage, async (e) => {
|
||||||
Logger(`Update into ${e.path}`);
|
Logger(`Update into ${e.path}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user