mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-19 04:31:29 +00:00
Fixed:
- Now reading error will be reported.
This commit is contained in:
2
src/lib
2
src/lib
Submodule src/lib updated: e4d825ae13...fbb3fcd8b4
26
src/main.ts
26
src/main.ts
@@ -2714,7 +2714,13 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
Logger(`Reading : ${file.path}`, LOG_LEVEL.VERBOSE);
|
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);
|
Logger(`Processing: ${file.path}`, LOG_LEVEL.VERBOSE);
|
||||||
content = await arrayBufferToBase64(contentBin);
|
try {
|
||||||
|
content = await arrayBufferToBase64(contentBin);
|
||||||
|
} catch (ex) {
|
||||||
|
Logger(`The file ${file.path} could not be encoded`);
|
||||||
|
Logger(ex, LOG_LEVEL.VERBOSE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
datatype = "newnote";
|
datatype = "newnote";
|
||||||
} else {
|
} else {
|
||||||
content = await this.app.vault.read(file);
|
content = await this.app.vault.read(file);
|
||||||
@@ -2722,7 +2728,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cache instanceof ArrayBuffer) {
|
if (cache instanceof ArrayBuffer) {
|
||||||
content = await arrayBufferToBase64(cache);
|
Logger(`Processing: ${file.path}`, LOG_LEVEL.VERBOSE);
|
||||||
|
try {
|
||||||
|
content = await arrayBufferToBase64(cache);
|
||||||
|
} catch (ex) {
|
||||||
|
Logger(`The file ${file.path} could not be encoded`);
|
||||||
|
Logger(ex, LOG_LEVEL.VERBOSE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
datatype = "newnote"
|
datatype = "newnote"
|
||||||
} else {
|
} else {
|
||||||
content = cache;
|
content = cache;
|
||||||
@@ -3071,7 +3084,14 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
async storeInternalFileToDatabase(file: InternalFileInfo, forceWrite = false) {
|
async storeInternalFileToDatabase(file: InternalFileInfo, forceWrite = false) {
|
||||||
const id = filename2idInternalMetadata(path2id(file.path));
|
const id = filename2idInternalMetadata(path2id(file.path));
|
||||||
const contentBin = await this.app.vault.adapter.readBinary(file.path);
|
const contentBin = await this.app.vault.adapter.readBinary(file.path);
|
||||||
const content = await arrayBufferToBase64(contentBin);
|
let content: string[];
|
||||||
|
try {
|
||||||
|
content = await arrayBufferToBase64(contentBin);
|
||||||
|
} catch (ex) {
|
||||||
|
Logger(`The file ${file.path} could not be encoded`);
|
||||||
|
Logger(ex, LOG_LEVEL.VERBOSE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const mtime = file.mtime;
|
const mtime = file.mtime;
|
||||||
return await runWithLock("file-" + id, false, async () => {
|
return await runWithLock("file-" + id, false, async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user