From 1d9107cc0408df886baec505012a0369c0118695 Mon Sep 17 00:00:00 2001 From: Dany LE Date: Mon, 3 Oct 2022 19:01:28 +0200 Subject: [PATCH] Move system package caches to tmp dir See issue #40 --- os/libs/packages.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/os/libs/packages.lua b/os/libs/packages.lua index 666ab5d..27b00b2 100644 --- a/os/libs/packages.lua +++ b/os/libs/packages.lua @@ -3,8 +3,11 @@ local vfs = require("vfs") local uid = ulib.uid(SESSION.user) packages._cache = function(y) - local p = vfs.ospath(y) - local f = io.open(p.."/packages.json", "w") + local p = vfs.ospath(y).."/packages.cache" + if y:find("^os://") then + p = __api__.tmpdir.."/packages.cache" + end + local f = io.open(p, "w") local has_cache = false local i = 1 local meta = {} @@ -28,7 +31,7 @@ packages._cache = function(y) f:write(table.concat(meta, ",")) f:close() if has_cache == false then - ulib.delete(p.."/packages.json"); + ulib.delete(p); end end end @@ -40,7 +43,10 @@ packages.list = function(paths) local first = true --std.f(__ROOT__.."/system/packages.json") for k,v in pairs(paths) do - local osp = vfs.ospath(v.."/packages.json") + local osp = vfs.ospath(v.."/packages.cache") + if v:find("^os://") then + osp = __api__.tmpdir.."/packages.cache" + end if ulib.exists(osp) == false then packages._cache(v) end @@ -116,4 +122,4 @@ packages.init = function(paths) end end -return packages \ No newline at end of file +return packages