Fix indexing files in sub-folders on the Desktop app

- `fs.readdir' func in node version 18.18.2 has buggy `recursive' option
  See nodejs/node#48640, effect-ts/effect#1801 for details

- We were recursing down a folder in two ways on the Desktop app.
  Remove `recursive: True' option to the `fs.readdirSync' method call
  to recurse down via app code only
This commit is contained in:
Debanjum Singh Solanky
2024-04-09 16:03:25 +05:30
parent a8dec1c9d5
commit f040418cf1
3 changed files with 6 additions and 12 deletions

View File

@@ -121,17 +121,17 @@ async function isPlainTextFile(filePath) {
}
async function processDirectory(filesToPush, folder) {
const files = fs.readdirSync(folder.path, { withFileTypes: true, recursive: true });
const files = fs.readdirSync(folder.path, { withFileTypes: true });
for (const file of files) {
const filePath = path.join(folder.path, file.name);
const filePath = path.join(file.path, file.name || '');
if (file.isFile() && await isPlainTextFile(filePath)) {
console.log(`Add ${file.name} in ${folder.path} for indexing`);
console.log(`Add ${file.name} in ${file.path} for indexing`);
filesToPush.push(filePath);
}
if (file.isDirectory()) {
await processDirectory(filesToPush, {'path': path.join(folder.path, file.name)});
await processDirectory(filesToPush, {'path': filePath});
}
}
}
@@ -497,11 +497,11 @@ app.whenReady().then(() => {
try {
const result = await todesktop.autoUpdater.checkForUpdates();
if (result.updateInfo) {
console.log("Update found:", result.updateInfo.version);
console.log("Desktop app update found:", result.updateInfo.version);
todesktop.autoUpdater.restartAndInstall();
}
} catch (e) {
console.log("Update check failed:", e);
console.warn("Desktop app update check failed:", e);
}
})