TagSpaces is an offline, open source, document manager with tagging support
fix: cleaning some error in console
Ilian Sapundshiev93e42c7e020f
diff --git a/src/main/extension-utils.ts b/src/main/extension-utils.tsindex 8d9b66cb3..94061420d 100644--- a/src/main/extension-utils.ts+++ b/src/main/extension-utils.ts@@ -25,8 +25,12 @@ export function getExtensions(reject(err);return;}- // Filter subdirectories- const subDirectories = files.filter((file) => file.isDirectory());+ // Filter subdirectories — skip dot-prefixed folders like `.ts`+ // (TagSpaces metadata) or `.bin`, which are never valid plugin+ // directories and would fail the package.json lookup below+ const subDirectories = files.filter(+ (file) => file.isDirectory() && !file.name.startsWith('.'),+ );resolve(processDirs(diff --git a/src/main/mainEvents.ts b/src/main/mainEvents.tsindex 94bb93e7b..ca191dcd8 100644--- a/src/main/mainEvents.ts+++ b/src/main/mainEvents.ts@@ -458,12 +458,28 @@ export default function loadMainEvents() {},);ipcMain.handle('loadTextFilePromise', async (event, path, isPreview) => {- const result = await loadTextFilePromise(path, isPreview);- return result;+ try {+ return await loadTextFilePromise(path, isPreview);+ } catch (err: any) {+ // ENOENT is an expected outcome when loading optional sidecar metadata+ // (e.g. .ts/<name>.json, tsft.jsonl). Surface as undefined to the+ // renderer — the caller's .then(undefined) is the same as a missing+ // file — and skip Electron's default "Error occurred in handler" log.+ if (err && err.code === 'ENOENT') {+ return undefined;+ }+ throw err;+ }});ipcMain.handle('getFileContentPromise', async (event, filePath, type) => {- const result = await getFileContentPromise(filePath, type);- return result;+ try {+ return await getFileContentPromise(filePath, type);+ } catch (err: any) {+ if (err && err.code === 'ENOENT') {+ return undefined;+ }+ throw err;+ }});ipcMain.handle('saveFilePromise',diff --git a/src/renderer/hooks/LocationIndexContextProvider.tsx b/src/renderer/hooks/LocationIndexContextProvider.tsxindex 976fca122..c68d8c2c4 100644--- a/src/renderer/hooks/LocationIndexContextProvider.tsx+++ b/src/renderer/hooks/LocationIndexContextProvider.tsx@@ -729,6 +729,9 @@ export const LocationIndexContextProvider = ({try {const locationPath = await getLocationPath(currentLocation);const ftPath = getMetaFullTextFilePath(locationPath);+ // loadTextFilePromise returns undefined for non-existent files (the+ // Electron main handler swallows ENOENT) — no separate existence check+ // needed, which saves a round-trip on S3/cloud locations.const ftContent = await currentLocation.loadTextFilePromise(ftPath);if (ftContent) {// Parse JSONL format (new) or JSON object (old backward compat)diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex af506b499..b41c50e1d 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -33,6 +33,23 @@ if (AppConfig.isCapacitor) {}}+/**+ * Shallow-clone `obj` dropping any function-valued properties.+ * Structured cloning (used by Electron's ipcRenderer.invoke) cannot transfer+ * functions — callers must strip them before IPC to avoid+ * "An object could not be cloned".+ */+function stripFunctions(obj: any): any {+ if (!obj || typeof obj !== 'object') return obj;+ const out: any = {};+ for (const key of Object.keys(obj)) {+ if (typeof obj[key] !== 'function') {+ out[key] = obj[key];+ }+ }+ return out;+}+export class CommonLocation implements TS.Location {uuid: string;newuuid?: string;@@ -386,9 +403,13 @@ export class CommonLocation implements TS.Location {resultsLimit,);} else if (AppConfig.isElectron) {+ // Structured-clone through IPC can't transfer functions. Strip any+ // function-valued entries (e.g. extractPDFcontent injected by the+ // indexer for the non-worker path) to avoid+ // "An object could not be cloned"return window.electronIO.ipcRenderer.invoke('listDirectoryPromise',- param,+ stripFunctions(param),mode,ignorePatterns,);@@ -409,7 +430,7 @@ export class CommonLocation implements TS.Location {} else if (AppConfig.isElectron) {return window.electronIO.ipcRenderer.invoke('listMetaDirectoryPromise',- param,+ stripFunctions(param),);}return Promise.reject(@@ -830,7 +851,7 @@ export class CommonLocation implements TS.Location {} else if (AppConfig.isElectron) {return window.electronIO.ipcRenderer.invoke('saveTextFilePromise',- param,+ stripFunctions(param),content,overwrite,);