From 1842017393241f1d7441921d157d9ff4d42eb6f7 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 25 Apr 2024 15:19:59 +0530 Subject: [PATCH] Skip trying to index deleted files, folders from Desktop app Previously app would crash on startup if desktop app was told to index a file that had been deleted afterwards --- src/interface/desktop/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/interface/desktop/main.js b/src/interface/desktop/main.js index 978b8220..db206065 100644 --- a/src/interface/desktop/main.js +++ b/src/interface/desktop/main.js @@ -170,11 +170,21 @@ function pushDataToKhoj (regenerate = false) { // Collect paths of all configured files to index for (const file of files) { + // Remove files that no longer exist + if (!fs.existsSync(file.path)) { + console.error(`${file.path} does not exist`); + continue; + } filesToPush.push(file.path); } // Collect paths of all indexable files in configured folders for (const folder of folders) { + // Remove folders that no longer exist + if (!fs.existsSync(folder.path)) { + console.error(`${folder.path} does not exist`); + continue; + } processDirectory(filesToPush, folder); }