mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-21 06:41:33 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5e6419504 | ||
|
|
1bf1e1540d | ||
|
|
be1e6b11ac |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-livesync",
|
"id": "obsidian-livesync",
|
||||||
"name": "Self-hosted LiveSync",
|
"name": "Self-hosted LiveSync",
|
||||||
"version": "0.17.9",
|
"version": "0.17.10",
|
||||||
"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.17.9",
|
"version": "0.17.10",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "obsidian-livesync",
|
"name": "obsidian-livesync",
|
||||||
"version": "0.17.9",
|
"version": "0.17.10",
|
||||||
"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.17.9",
|
"version": "0.17.10",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1423,7 +1423,7 @@ ${stringifyYaml(pluginConfig)}`;
|
|||||||
const releaser = await semaphore.acquire(1, "verifyAndRepair");
|
const releaser = await semaphore.acquire(1, "verifyAndRepair");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Logger(`Update into ${file.path}`);
|
Logger(`UPDATE DATABASE ${file.path}`);
|
||||||
await this.plugin.updateIntoDB(file, false, null, true);
|
await this.plugin.updateIntoDB(file, false, null, true);
|
||||||
i++;
|
i++;
|
||||||
Logger(`${i}/${files.length}\n${file.path}`, LOG_LEVEL.NOTICE, "verify");
|
Logger(`${i}/${files.length}\n${file.path}`, LOG_LEVEL.NOTICE, "verify");
|
||||||
|
|||||||
2
src/lib
2
src/lib
Submodule src/lib updated: 4ef5986b4d...2284678a59
32
src/main.ts
32
src/main.ts
@@ -19,6 +19,8 @@ import {
|
|||||||
getLocks,
|
getLocks,
|
||||||
WrappedNotice,
|
WrappedNotice,
|
||||||
Semaphore,
|
Semaphore,
|
||||||
|
getDocData,
|
||||||
|
isDocContentSame,
|
||||||
} from "./lib/src/utils";
|
} from "./lib/src/utils";
|
||||||
import { Logger, setLogger } from "./lib/src/logger";
|
import { Logger, setLogger } from "./lib/src/logger";
|
||||||
import { LocalPouchDB } from "./LocalPouchDB";
|
import { LocalPouchDB } from "./LocalPouchDB";
|
||||||
@@ -1214,7 +1216,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
await this.ensureDirectory(path);
|
await this.ensureDirectory(path);
|
||||||
try {
|
try {
|
||||||
const newFile = await this.app.vault.create(normalizePath(path), doc.data, {
|
const newFile = await this.app.vault.create(normalizePath(path), getDocData(doc.data), {
|
||||||
ctime: doc.ctime,
|
ctime: doc.ctime,
|
||||||
mtime: doc.mtime,
|
mtime: doc.mtime,
|
||||||
});
|
});
|
||||||
@@ -1304,7 +1306,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
await this.ensureDirectory(path);
|
await this.ensureDirectory(path);
|
||||||
try {
|
try {
|
||||||
await this.app.vault.modify(file, doc.data, { ctime: doc.ctime, mtime: doc.mtime });
|
await this.app.vault.modify(file, getDocData(doc.data), { ctime: doc.ctime, mtime: doc.mtime });
|
||||||
Logger(msg + path);
|
Logger(msg + path);
|
||||||
// this.batchFileChange = this.batchFileChange.filter((e) => e != file.path);
|
// this.batchFileChange = this.batchFileChange.filter((e) => e != file.path);
|
||||||
const xf = getAbstractFileByPath(file.path) as TFile;
|
const xf = getAbstractFileByPath(file.path) as TFile;
|
||||||
@@ -1866,7 +1868,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await runAll("UPDATE DATABASE", onlyInStorage, async (e) => {
|
await runAll("UPDATE DATABASE", onlyInStorage, async (e) => {
|
||||||
Logger(`Update into ${e.path}`);
|
Logger(`UPDATE DATABASE ${e.path}`);
|
||||||
await this.updateIntoDB(e, initialScan);
|
await this.updateIntoDB(e, initialScan);
|
||||||
});
|
});
|
||||||
if (!initialScan) {
|
if (!initialScan) {
|
||||||
@@ -1957,18 +1959,18 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
try {
|
try {
|
||||||
const doc = await this.localDatabase.getDBEntry(path, { rev: rev }, false, false, true);
|
const doc = await this.localDatabase.getDBEntry(path, { rev: rev }, false, false, true);
|
||||||
if (doc === false) return false;
|
if (doc === false) return false;
|
||||||
let data = doc.data;
|
let data = getDocData(doc.data)
|
||||||
if (doc.datatype == "newnote") {
|
if (doc.datatype == "newnote") {
|
||||||
data = base64ToString(doc.data);
|
data = base64ToString(data);
|
||||||
} else if (doc.datatype == "plain") {
|
} else if (doc.datatype == "plain") {
|
||||||
data = doc.data;
|
// NO OP.
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
deleted: doc.deleted || doc._deleted,
|
deleted: doc.deleted || doc._deleted,
|
||||||
ctime: doc.ctime,
|
ctime: doc.ctime,
|
||||||
mtime: doc.mtime,
|
mtime: doc.mtime,
|
||||||
rev: rev,
|
rev: rev,
|
||||||
data: data,
|
data: data
|
||||||
};
|
};
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (ex.status && ex.status == 404) {
|
if (ex.status && ex.status == 404) {
|
||||||
@@ -2462,11 +2464,13 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
if (shouldBeIgnored(file.path)) {
|
if (shouldBeIgnored(file.path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let content = "";
|
let content: string | string[];
|
||||||
let datatype: "plain" | "newnote" = "newnote";
|
let datatype: "plain" | "newnote" = "newnote";
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
if (!isPlainText(file.name)) {
|
if (!isPlainText(file.name)) {
|
||||||
|
Logger(`Reading : ${file.path}`, LOG_LEVEL.VERBOSE);
|
||||||
const contentBin = await this.app.vault.readBinary(file);
|
const contentBin = await this.app.vault.readBinary(file);
|
||||||
|
Logger(`Processing: ${file.path}`, LOG_LEVEL.VERBOSE);
|
||||||
content = await arrayBufferToBase64(contentBin);
|
content = await arrayBufferToBase64(contentBin);
|
||||||
datatype = "newnote";
|
datatype = "newnote";
|
||||||
} else {
|
} else {
|
||||||
@@ -2502,12 +2506,12 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
try {
|
try {
|
||||||
const old = await this.localDatabase.getDBEntry(fullPath, null, false, false);
|
const old = await this.localDatabase.getDBEntry(fullPath, null, false, false);
|
||||||
if (old !== false) {
|
if (old !== false) {
|
||||||
const oldData = { data: old.data, deleted: old._deleted || old.deleted, };
|
const oldData = { data: old.data, deleted: old._deleted || old.deleted };
|
||||||
const newData = { data: d.data, deleted: d._deleted || d.deleted };
|
const newData = { data: d.data, deleted: d._deleted || d.deleted };
|
||||||
if (JSON.stringify(oldData) == JSON.stringify(newData)) {
|
if (oldData.deleted != newData.deleted) return false;
|
||||||
Logger(msg + "Skipped (not changed) " + fullPath + ((d._deleted || d.deleted) ? " (deleted)" : ""), LOG_LEVEL.VERBOSE);
|
if (!isDocContentSame(old.data, newData.data)) return false;
|
||||||
return true;
|
Logger(msg + "Skipped (not changed) " + fullPath + ((d._deleted || d.deleted) ? " (deleted)" : ""), LOG_LEVEL.VERBOSE);
|
||||||
}
|
return true;
|
||||||
// d._rev = old._rev;
|
// d._rev = old._rev;
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
@@ -2569,7 +2573,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
async getPluginList(): Promise<{ plugins: PluginList; allPlugins: DevicePluginList; thisDevicePlugins: DevicePluginList }> {
|
async getPluginList(): Promise<{ plugins: PluginList; allPlugins: DevicePluginList; thisDevicePlugins: DevicePluginList }> {
|
||||||
const db = this.localDatabase.localDatabase;
|
const db = this.localDatabase.localDatabase;
|
||||||
const docList = await db.allDocs<PluginDataEntry>({ startkey: PSCHeader, endkey: PSCHeaderEnd, include_docs: false });
|
const docList = await db.allDocs<PluginDataEntry>({ startkey: PSCHeader, endkey: PSCHeaderEnd, include_docs: false });
|
||||||
const oldDocs: PluginDataEntry[] = ((await Promise.all(docList.rows.map(async (e) => await this.localDatabase.getDBEntry(e.id)))).filter((e) => e !== false) as LoadedEntry[]).map((e) => JSON.parse(e.data));
|
const oldDocs: PluginDataEntry[] = ((await Promise.all(docList.rows.map(async (e) => await this.localDatabase.getDBEntry(e.id)))).filter((e) => e !== false) as LoadedEntry[]).map((e) => JSON.parse(getDocData(e.data)));
|
||||||
const plugins: { [key: string]: PluginDataEntry[] } = {};
|
const plugins: { [key: string]: PluginDataEntry[] } = {};
|
||||||
const allPlugins: { [key: string]: PluginDataEntry } = {};
|
const allPlugins: { [key: string]: PluginDataEntry } = {};
|
||||||
const thisDevicePlugins: { [key: string]: PluginDataEntry } = {};
|
const thisDevicePlugins: { [key: string]: PluginDataEntry } = {};
|
||||||
|
|||||||
@@ -42,9 +42,12 @@
|
|||||||
- New Feature: Now we can synchronise automatically after merging conflicts.
|
- New Feature: Now we can synchronise automatically after merging conflicts.
|
||||||
|
|
||||||
- 0.17.9
|
- 0.17.9
|
||||||
- Fixed: Conflict merge of internal files is no longer broken.
|
- Fixed: Conflict merge of internal files is no longer broken.
|
||||||
- Improved: Smoother status display inside the editor.
|
- Improved: Smoother status display inside the editor.
|
||||||
|
|
||||||
|
- 0.17.10
|
||||||
|
- Fixed: Large file synchronising has been now addressed!
|
||||||
|
Note: When synchronising large files, we have to set `Chunk size` to lower than 50, disable `Read chunks online`, `Batch size` should be set 50-100, and `Batch limit` could be around 20.
|
||||||
### 0.16.0
|
### 0.16.0
|
||||||
- Now hidden files need not be scanned. Changes will be detected automatically.
|
- Now hidden files need not be scanned. Changes will be detected automatically.
|
||||||
- If you want it to back to its previous behaviour, please disable `Monitor changes to internal files`.
|
- If you want it to back to its previous behaviour, please disable `Monitor changes to internal files`.
|
||||||
|
|||||||
Reference in New Issue
Block a user