From 502de4605d72921bc55707624a4b3b6c761211c6 Mon Sep 17 00:00:00 2001 From: emrtnn Date: Mon, 3 Aug 2026 14:16:43 +0200 Subject: [PATCH] fix(pass): reduce fileInfo calls to fit noctalia's CPU budget (#228) --- pass/plugin.toml | 2 +- pass/service.luau | 50 ++++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pass/plugin.toml b/pass/plugin.toml index 390e25f..061d855 100644 --- a/pass/plugin.toml +++ b/pass/plugin.toml @@ -1,6 +1,6 @@ id = "emrtnn/pass" name = "Pass" -version = "0.0.1" +version = "0.1.0" plugin_api = 3 author = "emrtnn" license = "MIT" diff --git a/pass/service.luau b/pass/service.luau index 9da3559..e1fb780 100644 --- a/pass/service.luau +++ b/pass/service.luau @@ -29,32 +29,34 @@ local function scan(dir, prefix) for _, name in ipairs(names) do -- Ignore hidden files/directories (.git, .extensions, .gpg-id, ...) if name:sub(1, 1) ~= "." then - local full = dir .. "/" .. name - local info = noctalia.fileInfo(full) + -- listDir already proved the name exists, so an entry needs no stat. + -- Only non-entry names get one, to decide whether to recurse. + if name:sub(-4) == ".gpg" then + local path = prefix .. name:sub(1, -5) - if info then - if info.isDir then + local title = path + local subtitle = "" + + local lastSlash = path:match("^.*()/") + + if lastSlash then + subtitle = path:sub(1, lastSlash - 1) + title = path:sub(lastSlash + 1) + end + + table.insert(entries, { + id = path, + path = path, + title = title, + subtitle = subtitle, + }) + + else + local full = dir .. "/" .. name + local info = noctalia.fileInfo(full) + + if info and info.isDir then scan(full, prefix .. name .. "/") - - elseif name:sub(-4) == ".gpg" then - local path = prefix .. name:sub(1, -5) - - local title = path - local subtitle = "" - - local lastSlash = path:match("^.*()/") - - if lastSlash then - subtitle = path:sub(1, lastSlash - 1) - title = path:sub(lastSlash + 1) - end - - table.insert(entries, { - id = path, - path = path, - title = title, - subtitle = subtitle, - }) end end end