mirror of
https://github.com/antos-rde/antos-backend.git
synced 2024-12-25 04:38:22 +01:00
fix: query home dir from user id, if fail, fallback to default value
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
This commit is contained in:
parent
32bd62ae86
commit
37f68f0e04
11
libs/vfs.lua
11
libs/vfs.lua
@ -2,14 +2,21 @@ local vfs = {}
|
||||
|
||||
vfs.ospath = function(path)
|
||||
local user = SESSION.user
|
||||
local uid = ulib.uid(SESSION.user)
|
||||
local prefix = string.match(path, "%a+:/")
|
||||
local home = ulib.home_dir(uid.id)
|
||||
if not home then
|
||||
home = string.format("%s/%s",VFS_HOME, user)
|
||||
else
|
||||
LOG_DEBUG("User home is %s", home)
|
||||
end
|
||||
local os_path = nil
|
||||
if (prefix ~= nil) then
|
||||
local suffix = string.gsub(path, prefix, "")
|
||||
if prefix == "home:/" then
|
||||
os_path = string.format(VFS_HOME, user) .. '/' .. suffix
|
||||
os_path = home.. '/' .. suffix
|
||||
elseif prefix == "desktop:/" then
|
||||
os_path = string.format(VFS_HOME, user) .. "/.antos/desktop/" .. suffix
|
||||
os_path = home .. "/.antos/desktop/" .. suffix
|
||||
elseif prefix == "shared:/" then
|
||||
os_path = require("shared").ospath(ulib.trim(suffix, "/"))
|
||||
elseif prefix == "os:/" then
|
||||
|
@ -15,7 +15,13 @@ package.path = package.path..";"..WWW_ROOT .. '/libs/?.lua'
|
||||
require("common")
|
||||
|
||||
DIR_SEP = "/"
|
||||
VFS_HOME = "/home/%s"
|
||||
VFS_HOME = os.getenv("HOME_ROOT")
|
||||
if not VFS_HOME then
|
||||
VFS_HOME="/home"
|
||||
end
|
||||
|
||||
LOG_DEBUG("VFS_HOME=%s", VFS_HOME)
|
||||
|
||||
-- class path: path.to.class
|
||||
CONTROLLER_ROOT = "os.controllers"
|
||||
MODEL_ROOT = "os.models"
|
||||
|
Loading…
Reference in New Issue
Block a user