From bb4b764586b455e2b07d8ac51b8786d547f0231a Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Sat, 25 Nov 2023 02:21:44 +0900 Subject: [PATCH] - Fixed: - No more infinity loops on larger files. - Show message on decode error. - Refactored: - Fixed to avoid obsolete global variables. --- src/lib | 2 +- src/main.ts | 4 ++-- src/utils.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib b/src/lib index 2ea80a4..f9aeaf6 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 2ea80a40c11c367efcb6861dbf3c4ee076b705b9 +Subproject commit f9aeaf6a2d8cb42deafc0bd89d6a43b4654d18fd diff --git a/src/main.ts b/src/main.ts index 34a937c..2cec12e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1306,9 +1306,9 @@ Note: We can always able to read V1 format. It will be progressively converted. try { let outFile; if (mode == "create") { - outFile = await createFile(normalizePath(path), writeData, { ctime: doc.ctime, mtime: doc.mtime, }); + outFile = await createFile(this.app,normalizePath(path), writeData, { ctime: doc.ctime, mtime: doc.mtime, }); } else { - await modifyFile(file, writeData, { ctime: doc.ctime, mtime: doc.mtime }); + await modifyFile(this.app,file, writeData, { ctime: doc.ctime, mtime: doc.mtime }); outFile = getAbstractFileByPath(getPathFromTFile(file)) as TFile; } Logger(msg + path); diff --git a/src/utils.ts b/src/utils.ts index 6a4c2dd..da95aa5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -303,14 +303,14 @@ export function flattenObject(obj: Record, path: return ret; } -export function modifyFile(file: TFile, data: string | ArrayBuffer, options?: DataWriteOptions) { +export function modifyFile(app: App, file: TFile, data: string | ArrayBuffer, options?: DataWriteOptions) { if (typeof (data) === "string") { return app.vault.modify(file, data, options); } else { return app.vault.modifyBinary(file, data, options); } } -export function createFile(path: string, data: string | ArrayBuffer, options?: DataWriteOptions): Promise { +export function createFile(app: App, path: string, data: string | ArrayBuffer, options?: DataWriteOptions): Promise { if (typeof (data) === "string") { return app.vault.create(path, data, options); } else {