Skip to content

Commit f040418

Browse files
committed
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
1 parent a8dec1c commit f040418

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/interface/desktop/main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ async function isPlainTextFile(filePath) {
121121
}
122122

123123
async function processDirectory(filesToPush, folder) {
124-
const files = fs.readdirSync(folder.path, { withFileTypes: true, recursive: true });
124+
const files = fs.readdirSync(folder.path, { withFileTypes: true });
125125

126126
for (const file of files) {
127-
const filePath = path.join(folder.path, file.name);
127+
const filePath = path.join(file.path, file.name || '');
128128
if (file.isFile() && await isPlainTextFile(filePath)) {
129-
console.log(`Add ${file.name} in ${folder.path} for indexing`);
129+
console.log(`Add ${file.name} in ${file.path} for indexing`);
130130
filesToPush.push(filePath);
131131
}
132132

133133
if (file.isDirectory()) {
134-
await processDirectory(filesToPush, {'path': path.join(folder.path, file.name)});
134+
await processDirectory(filesToPush, {'path': filePath});
135135
}
136136
}
137137
}
@@ -497,11 +497,11 @@ app.whenReady().then(() => {
497497
try {
498498
const result = await todesktop.autoUpdater.checkForUpdates();
499499
if (result.updateInfo) {
500-
console.log("Update found:", result.updateInfo.version);
500+
console.log("Desktop app update found:", result.updateInfo.version);
501501
todesktop.autoUpdater.restartAndInstall();
502502
}
503503
} catch (e) {
504-
console.log("Update check failed:", e);
504+
console.warn("Desktop app update check failed:", e);
505505
}
506506
})
507507

src/interface/desktop/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"axios": "^1.6.4",
2121
"cron": "^2.4.3",
2222
"electron-store": "^8.1.0",
23-
"fs": "^0.0.1-security",
2423
"file-type": "^16.2.0"
2524
}
2625
}

src/interface/desktop/yarn.lock

-5
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,6 @@ fs.realpath@^1.0.0:
536536
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
537537
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
538538

539-
fs@^0.0.1-security:
540-
version "0.0.1-security"
541-
resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4"
542-
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==
543-
544539
function-bind@^1.1.1:
545540
version "1.1.1"
546541
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"

0 commit comments

Comments
 (0)