diff --git a/controllers/SystemController.lua b/controllers/SystemController.lua index 6b5f926..0703411 100644 --- a/controllers/SystemController.lua +++ b/controllers/SystemController.lua @@ -53,7 +53,7 @@ function SystemController:settings(...) if user then local ospath = require("vfs").ospath("home:///", user) if REQUEST and REQUEST.json then - local file_path = ospath .. "/" .. ".settings.json" + local file_path = ospath .. "/.antos/settings/" .. "settings.json" local f = io.open(file_path, "w") if f then f:write(REQUEST.json) diff --git a/libs/packages.lua b/libs/packages.lua index 27fadaa..e300333 100644 --- a/libs/packages.lua +++ b/libs/packages.lua @@ -26,14 +26,13 @@ packages._cache = function(y) local name = utils.basename(v.path) local mt = JSON.decodeString(f1:read("*all")) mt.path = v.path - meta[i] = '"' .. name .. '":' .. JSON.encode(mt) - i = i + 1 + meta[name] = mt f1:close() has_cache = true; end end end - f:write(table.concat(meta, ",")) + f:write(JSON.encode(meta)) f:close() if has_cache == false then ulib.delete(file_path); @@ -44,8 +43,10 @@ end -- we will change this later packages.list = function(paths) std.json() - std.t("{\"result\" : { ") - local first = true + local ret = { + result = {}, + error = false + } for k, v in pairs(paths) do local p = vfs.ospath(v) local f1 = p.."/packages.json" @@ -60,15 +61,16 @@ packages.list = function(paths) end if ulib.exists(osp) then LOG_DEBUG("Use package cache files at: %s", osp) - if first == false then - std.t(",") - else - first = false + local data = JSON.decodeFile(osp) + LOG_ERROR("ERROR: %s", data) + if data then + for k1,v1 in pairs(data) do + ret.result[k1] = v1 + end end - std.f(osp) end end - std.t("}, \"error\":false}") + std.t(JSON.encode(ret)) end -- generate the packages caches diff --git a/libs/uman.lua b/libs/uman.lua index b268e9b..9692e33 100644 --- a/libs/uman.lua +++ b/libs/uman.lua @@ -4,9 +4,25 @@ uman.userinfo = function(user) local info = {} local uid = ulib.uid(user) if uid then + -- create the following directory structure if does not exists + local dir = require('vfs').ospath("home:///.antos", user) + if not ulib.exists(dir) then + ulib.mkdir(dir) + ulib.chown(dir, uid.id, uid.gid) + end + local setting_dir = dir.."/settings" + if not ulib.exists(setting_dir) then + ulib.mkdir(setting_dir) + ulib.chown(setting_dir, uid.id, uid.gid) + end + local desktop_dir = dir.."/desktop" + if not ulib.exists(desktop_dir) then + ulib.mkdir(desktop_dir) + ulib.chown(desktop_dir, uid.id, uid.gid) + end -- read the setting -- use the decodeFile function of JSON instead - local file = require('vfs').ospath("home:///").."/.settings.json" + local file = require('vfs').ospath("home:///").."/.antos/settings/settings.json" local st = JSON.decodeFile(file) if(st) then info = st diff --git a/libs/vfs.lua b/libs/vfs.lua index 764e8f3..18132e1 100644 --- a/libs/vfs.lua +++ b/libs/vfs.lua @@ -9,7 +9,7 @@ vfs.ospath = function(path) if prefix == "home:/" then os_path = string.format(VFS_HOME, user) .. '/' .. suffix elseif prefix == "desktop:/" then - os_path = string.format(VFS_HOME, user) .. "/.desktop/" .. suffix + os_path = string.format(VFS_HOME, user) .. "/.antos/desktop/" .. suffix elseif prefix == "shared:/" then os_path = require("shared").ospath(ulib.trim(suffix, "/")) elseif prefix == "os:/" then