From c22d3183a46b28aeb5eba3447533c0877d502780 Mon Sep 17 00:00:00 2001 From: William Stein Date: Thu, 16 Nov 2023 03:35:05 +0000 Subject: [PATCH] properly exclude hidden top level files --- websocketfs/lib/metadata-file.ts | 5 ++++- websocketfs/lib/sftp-fuse.ts | 6 +++--- websocketfs/package.json | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/websocketfs/lib/metadata-file.ts b/websocketfs/lib/metadata-file.ts index 13997bd..185f10f 100644 --- a/websocketfs/lib/metadata-file.ts +++ b/websocketfs/lib/metadata-file.ts @@ -117,7 +117,10 @@ export class MetadataFile { }; private cacheAttrs = (i: number) => { - const v = this.metadataFileContents[i].split("\0"); + const v = this.metadataFileContents[i]?.split("\0"); + if (v == null || v.length <= 1) { + return { errno: -2 }; + } const data = v[1].split(" "); const mtime = new Date(parseFloat(data[0]) * 1000); const attr = { diff --git a/websocketfs/lib/sftp-fuse.ts b/websocketfs/lib/sftp-fuse.ts index 55ec5e9..02cdaeb 100644 --- a/websocketfs/lib/sftp-fuse.ts +++ b/websocketfs/lib/sftp-fuse.ts @@ -267,7 +267,7 @@ export default class SftpFuse { cb(errno ?? 0, attr); return; } - if (this.meta?.isReady()) { + if (!path.startsWith("/.") && this.meta?.isReady()) { const { errno, attr } = this.meta.getattr(path); cb(errno ?? 0, attr); return; @@ -298,7 +298,7 @@ export default class SftpFuse { cb(errno ?? 0, attr); return; } - if (this.meta?.isReady()) { + if (!path.startsWith("/.") && this.meta?.isReady()) { const { errno, attr } = this.meta.getattr(path); cb(errno ?? 0, attr); return; @@ -394,7 +394,7 @@ export default class SftpFuse { cb(0, this.dirCache.get(path)); return; } - if (this.meta?.isReady() && !path.startsWith(".")) { + if (!path.startsWith("/.") && this.meta?.isReady()) { try { cb(0, this.meta.readdir(path)); } catch (err) { diff --git a/websocketfs/package.json b/websocketfs/package.json index f510c6a..867a192 100644 --- a/websocketfs/package.json +++ b/websocketfs/package.json @@ -1,6 +1,6 @@ { "name": "websocketfs", - "version": "0.12.2", + "version": "0.12.4", "description": "Like sshfs, but over a WebSocket", "main": "./dist/lib/index.js", "scripts": {