Skip to content

Commit

Permalink
fix major bug where directory listings were truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
williamstein committed Nov 11, 2023
1 parent e0f2406 commit 437ec54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions websocketfs/lib/sftp-fuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,22 @@ export default class SftpFuse {
return;
}
try {
let handle, items;
let handle;
let items: any[] = [];
try {
handle = await callback(this.sftp.opendir, path);
log("readdir - opendir got a handle", handle._handle);
items = await callback(this.sftp.readdir, handle);
// We read repeatedly chunks of files from the backend until done.
// (Usually 64 files are sent, but looking at the source code if the names
// are really long, then I think less could be, so assuming that less than
// 64 means we are done may be a bad optimization to make!).
while (true) {
const nextItems = await callback(this.sftp.readdir, handle);
if (typeof nextItems == "boolean" || nextItems.length == 0) {
break;
}
items = items.concat(nextItems);
}
} finally {
// do not block on this.
this.sftp.close(handle, (err) => {
Expand All @@ -367,9 +378,6 @@ export default class SftpFuse {
}
//log("readdir - items", items);
// todo: cache attrs from items (?)
if (typeof items == "boolean") {
throw Error("readdir fail");
}
const filenames = items.map(({ filename }) => filename);
if (this.attrCache != null) {
for (const { filename, stats, longname } of items) {
Expand Down
2 changes: 1 addition & 1 deletion websocketfs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "websocketfs",
"version": "0.10.2",
"version": "0.10.3",
"description": "Like sshfs, but over a WebSocket",
"main": "./dist/lib/index.js",
"scripts": {
Expand Down

0 comments on commit 437ec54

Please sign in to comment.