mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-14 19:41:16 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a8e52425e |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-livesync",
|
"id": "obsidian-livesync",
|
||||||
"name": "Self-hosted LiveSync",
|
"name": "Self-hosted LiveSync",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"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.6.0",
|
"version": "0.6.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "obsidian-livesync",
|
"name": "obsidian-livesync",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"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.6.0",
|
"version": "0.6.1",
|
||||||
"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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
MILSTONE_DOCID,
|
MILSTONE_DOCID,
|
||||||
DatabaseConnectingStatus,
|
DatabaseConnectingStatus,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { resolveWithIgnoreKnownError, delay, path2id, runWithLock } from "./utils";
|
import { resolveWithIgnoreKnownError, delay, path2id, runWithLock, isPlainText } from "./utils";
|
||||||
import { Logger } from "./logger";
|
import { Logger } from "./logger";
|
||||||
import { checkRemoteVersion, connectRemoteCouchDB, getLastPostFailedBySize } from "./utils_couchdb";
|
import { checkRemoteVersion, connectRemoteCouchDB, getLastPostFailedBySize } from "./utils_couchdb";
|
||||||
import { decrypt, encrypt } from "./e2ee";
|
import { decrypt, encrypt } from "./e2ee";
|
||||||
@@ -501,18 +501,6 @@ export class LocalPouchDB {
|
|||||||
Logger(`deleteDBEntryPrefix:deleted ${deleteCount} items, skipped ${notfound}`);
|
Logger(`deleteDBEntryPrefix:deleted ${deleteCount} items, skipped ${notfound}`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
isPlainText(filename: string): boolean {
|
|
||||||
if (filename.endsWith(".md")) return true;
|
|
||||||
if (filename.endsWith(".txt")) return true;
|
|
||||||
if (filename.endsWith(".svg")) return true;
|
|
||||||
if (filename.endsWith(".html")) return true;
|
|
||||||
if (filename.endsWith(".csv")) return true;
|
|
||||||
if (filename.endsWith(".css")) return true;
|
|
||||||
if (filename.endsWith(".js")) return true;
|
|
||||||
if (filename.endsWith(".xml")) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
async putDBEntry(note: LoadedEntry) {
|
async putDBEntry(note: LoadedEntry) {
|
||||||
await this.waitForGCComplete();
|
await this.waitForGCComplete();
|
||||||
let leftData = note.data;
|
let leftData = note.data;
|
||||||
@@ -524,7 +512,7 @@ export class LocalPouchDB {
|
|||||||
let plainSplit = false;
|
let plainSplit = false;
|
||||||
let cacheUsed = 0;
|
let cacheUsed = 0;
|
||||||
const userpasswordHash = this.h32Raw(new TextEncoder().encode(this.settings.passphrase));
|
const userpasswordHash = this.h32Raw(new TextEncoder().encode(this.settings.passphrase));
|
||||||
if (this.isPlainText(note._id)) {
|
if (isPlainText(note._id)) {
|
||||||
pieceSize = MAX_DOC_SIZE;
|
pieceSize = MAX_DOC_SIZE;
|
||||||
plainSplit = true;
|
plainSplit = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
diff_result,
|
diff_result,
|
||||||
FLAGMD_REDFLAG,
|
FLAGMD_REDFLAG,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { base64ToString, arrayBufferToBase64, base64ToArrayBuffer, isValidPath, versionNumberString2Number, id2path, path2id, runWithLock, shouldBeIgnored, getProcessingCounts, setLockNotifier } from "./utils";
|
import { base64ToString, arrayBufferToBase64, base64ToArrayBuffer, isValidPath, versionNumberString2Number, id2path, path2id, runWithLock, shouldBeIgnored, getProcessingCounts, setLockNotifier, isPlainText } from "./utils";
|
||||||
import { Logger, setLogger } from "./logger";
|
import { Logger, setLogger } from "./logger";
|
||||||
import { LocalPouchDB } from "./LocalPouchDB";
|
import { LocalPouchDB } from "./LocalPouchDB";
|
||||||
import { LogDisplayModal } from "./LogDisplayModal";
|
import { LogDisplayModal } from "./LogDisplayModal";
|
||||||
@@ -48,7 +48,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
showHistory(file: TFile) {
|
showHistory(file: TFile) {
|
||||||
if (!this.settings.useHistory) {
|
if (!this.settings.useHistory) {
|
||||||
Logger("You have to enable Use history in misc.", LOG_LEVEL.NOTICE);
|
Logger("You have to enable Use History in misc.", LOG_LEVEL.NOTICE);
|
||||||
} else {
|
} else {
|
||||||
new DocumentHistoryModal(this.app, this, file).open();
|
new DocumentHistoryModal(this.app, this, file).open();
|
||||||
}
|
}
|
||||||
@@ -1217,7 +1217,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
await this.localDatabase.waitForGCComplete();
|
await this.localDatabase.waitForGCComplete();
|
||||||
let content = "";
|
let content = "";
|
||||||
let datatype: "plain" | "newnote" = "newnote";
|
let datatype: "plain" | "newnote" = "newnote";
|
||||||
if (file.extension != "md") {
|
if (!isPlainText(file.name)) {
|
||||||
const contentBin = await this.app.vault.readBinary(file);
|
const contentBin = await this.app.vault.readBinary(file);
|
||||||
content = await arrayBufferToBase64(contentBin);
|
content = await arrayBufferToBase64(contentBin);
|
||||||
datatype = "newnote";
|
datatype = "newnote";
|
||||||
|
|||||||
13
src/utils.ts
13
src/utils.ts
@@ -234,3 +234,16 @@ export function runWithLock<T>(key: unknown, ignoreWhenRunning: boolean, proc: (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isPlainText(filename: string): boolean {
|
||||||
|
if (filename.endsWith(".md")) return true;
|
||||||
|
if (filename.endsWith(".txt")) return true;
|
||||||
|
if (filename.endsWith(".svg")) return true;
|
||||||
|
if (filename.endsWith(".html")) return true;
|
||||||
|
if (filename.endsWith(".csv")) return true;
|
||||||
|
if (filename.endsWith(".css")) return true;
|
||||||
|
if (filename.endsWith(".js")) return true;
|
||||||
|
if (filename.endsWith(".xml")) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user