From 35f3c6f89e77232b9f26172452b211de6b787f49 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 8 Oct 2023 11:41:44 +1000 Subject: [PATCH] implement the dirstat extension in exportfs, greatly improving perf for OpenOS clients --- lib/netutil.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/netutil.lua b/lib/netutil.lua index f827f22..359673e 100644 --- a/lib/netutil.lua +++ b/lib/netutil.lua @@ -16,6 +16,14 @@ end function netutil.exportfs(path) -- string -- boolean -- Export the directory *path* over RPC. local path = "/"..table.concat(fs.segments(path),"/") local px = require("unionfs").create(path) + function px.dirstat(p) + local rt = {} + for k,v in ipairs(px.list(p)) do + local fp = p.."/"..v + rt[v] = {px.isDirectory(fp), px.size(fp), px.lastModified(fp)} + end + return rt + end for k,v in pairs(px) do rpc.register("fs_"..path.."_"..k,v) print("fs_"..path.."_"..k)