summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-03-16 22:45:54 +0800
committerruki <[email protected]>2018-03-16 10:35:30 +0800
commita799d50c58621b7dccd0c2c646c24b06d4df191a (patch)
tree0cc187b27d83ec99fccaf01dec17a92cd294436d
parent205132b53a8f0667f1dd5778555ce2c57be2e687 (diff)
improve tmpdir and stats
-rw-r--r--xmake/actions/build/statistics.lua11
-rw-r--r--xmake/core/base/os.lua12
2 files changed, 17 insertions, 6 deletions
diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua
index e0c79343a..714073db3 100644
--- a/xmake/actions/build/statistics.lua
+++ b/xmake/actions/build/statistics.lua
@@ -121,7 +121,16 @@ function main()
if not os.isdir(outputdir) then
import("devel.git.clone")
clone("https://github.com/tboox/xmake-stats.git", {depth = 1, branch = "master", outputdir = outputdir})
- print("post ok!")
+ print("post to traffic ok!")
+ end
+
+ -- download the xmake-stats releases to update the release stats info in github
+ local releasefile = outputdir .. ".release"
+ if not os.isfile(releasefile) then
+ import("net.http.download")
+ local version = os.versioninfo().version
+ download(format("https://github.com/tboox/xmake-stats/releases/download/v%d.%d.%d/%s", version.major, version.minor, version.alter, os.host()), releasefile)
+ print("post to releases ok!")
end
-- leave environment
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index c5b1a2867..96bf998dc 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -469,22 +469,24 @@ function os.tmpdir()
end
-- make sub-directory name
- local subdir = utils.ifelse(os._FAKEROOT, ".xmakefake", ".xmake")
+ local subdir = (os._FAKEROOT and ".xmakefake" or ".xmake") .. (os.uid().euid or "")
-- get a temporary directory for each user
- local tmpdir = path.join(os._tmpdir(), subdir .. (os.uid().euid or ""))
+ local tmpdir = path.join(os._tmpdir(), subdir, os.date("%y%m%d"))
- -- ensure this directory exist
+ -- ensure this directory exist and remove the previous directory
if not os.isdir(tmpdir) then
os.mkdir(tmpdir)
+ local predir = path.join(os._tmpdir(), subdir, os.date("%y%m%d", os.time() - 24 * 60 * 60))
+ if os.isdir(predir) then
+ os.rmdir(predir)
+ end
end
return tmpdir
end
-- generate the temporary file path
function os.tmpfile()
-
- -- make it
return path.join(os.tmpdir(), "_" .. (hash.uuid():gsub("-", "")))
end