Skip to content

Commit

Permalink
Fix indexing files in sub-folders on the Desktop app
Browse files Browse the repository at this point in the history
- `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
  • Loading branch information
debanjum committed Apr 9, 2024
1 parent fecdb28 commit cd8d5d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/interface/desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
}
}
Expand Down Expand Up @@ -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);
}
})

Expand Down
1 change: 0 additions & 1 deletion src/interface/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"axios": "^1.6.4",
"cron": "^2.4.3",
"electron-store": "^8.1.0",
"fs": "^0.0.1-security",
"file-type": "^16.2.0"
}
}
5 changes: 0 additions & 5 deletions src/interface/desktop/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fs@^0.0.1-security:
version "0.0.1-security"
resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4"
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
Expand Down

0 comments on commit cd8d5d8

Please sign in to comment.