diff options
| author | ruki <[email protected]> | 2020-02-12 00:17:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-11 19:43:22 +0800 |
| commit | bbebeccae7034f75c246e8ab05c4d03f236cf096 (patch) | |
| tree | a4c760b18327286406f936588200dac70e42c59a | |
| parent | a192c845ab453e7d0da1a4a7cbaa9acb834746d5 (diff) | |
improve tmpdir
| -rw-r--r-- | xmake/actions/update/main.lua | 5 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 20 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 8 |
3 files changed, 21 insertions, 12 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index 5b322907f..79ce6c7b1 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -335,13 +335,14 @@ function main() cprint("update version ${green}%s${clear} from ${underline}%s${clear} ..", version, mainurls[1]) end - -- the download task - local sourcedir = path.join(os.tmpdir(), "xmakesrc", version) + -- get the temporary source directory without ramdisk (maybe too large) + local sourcedir = path.join(os.tmpdir({ramdisk = false}), "xmakesrc", version) vprint("prepared to download to temp dir %s ..", sourcedir) -- all user provided urls are considered as git url since check has been performed in fetch_version local install_from_git = not is_official or git.checkurl(mainurls[1]) + -- the download task local download_task = function () for idx, url in ipairs(mainurls) do utils.clearline() diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 5daefc471..5c193a48d 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -515,7 +515,7 @@ function os.rmdir(...) end -- get the temporary directory -function os.tmpdir() +function os.tmpdir(opt) -- is in fakeroot? @note: uid always be 0 in root and fakeroot if os._FAKEROOT == nil then @@ -528,10 +528,18 @@ function os.tmpdir() end -- get root tmpdir - if os._ROOT_TMPDIR == nil then - os._ROOT_TMPDIR = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + local tmpdir_root = nil + if opt and opt.ramdisk == false then + if os._ROOT_TMPDIR == nil then + os._ROOT_TMPDIR = (os.getenv("XMAKE_TMPDIR") or os.getenv("TMPDIR") or os._tmpdir()):trim() + end + tmpdir_root = os._ROOT_TMPDIR + else + if os._ROOT_TMPDIR_RAM == nil then + os._ROOT_TMPDIR_RAM = (os.getenv("XMAKE_TMPDIR") or os._ramdir() or os.getenv("TMPDIR") or os._tmpdir()):trim() + end + tmpdir_root = os._ROOT_TMPDIR_RAM end - local tmpdir_root = os._ROOT_TMPDIR -- make sub-directory name local subdir = (os._FAKEROOT and ".xmakefake" or ".xmake") .. (os.uid().euid or "") @@ -547,8 +555,8 @@ function os.tmpdir() end -- generate the temporary file path -function os.tmpfile(key) - return path.join(os.tmpdir(), "_" .. (hash.uuid4(key):gsub("-", ""))) +function os.tmpfile(key, opt) + return path.join(os.tmpdir(opt), "_" .. (hash.uuid4(key):gsub("-", ""))) end -- exit program diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index b69c68f25..f6ce8e6b4 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -262,13 +262,13 @@ function sandbox_os.curdir() end -- get the temporary directory -function sandbox_os.tmpdir() - return assert(os.tmpdir()) +function sandbox_os.tmpdir(opt) + return assert(os.tmpdir(opt)) end -- get the temporary file -function sandbox_os.tmpfile(key) - return assert(os.tmpfile(key)) +function sandbox_os.tmpfile(key, opt) + return assert(os.tmpfile(key, opt)) end -- get the script directory |
