diff options
| author | ruki <[email protected]> | 2021-04-30 22:35:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-30 22:35:30 +0800 |
| commit | 79826212f9db4c949f8a4b462a1dfb92caffa5ed (patch) | |
| tree | d8f5041b5ce37b2322f69d129ab33d7384d06849 | |
| parent | b2a6155c6288b251738b0b626096286615211df1 (diff) | |
cache mainurls
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/package/repository.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/xmake/core/sandbox/modules/import/core/package/repository.lua b/xmake/core/sandbox/modules/import/core/package/repository.lua index 56e45f0c1..e05a98aaf 100644 --- a/xmake/core/sandbox/modules/import/core/package/repository.lua +++ b/xmake/core/sandbox/modules/import/core/package/repository.lua @@ -24,6 +24,7 @@ local sandbox_core_package_repository = sandbox_core_package_repository or {} -- load modules local global = require("base/global") local project = require("project/project") +local localcache = require("cache/localcache") local repository = require("package/repository") local raise = require("sandbox/modules/raise") local import = require("sandbox/modules/import") @@ -109,13 +110,16 @@ function sandbox_core_package_repository.repositories(is_global) -- add main global xmake repository if is_global and global.get("network") ~= "private" then - -- import fasturl - import("net.fasturl") - - -- sort main urls - local mainurls = {"https://github.com/xmake-io/xmake-repo.git", "https://gitlab.com/tboox/xmake-repo.git", "https://gitee.com/tboox/xmake-repo.git"} - fasturl.add(mainurls) - mainurls = fasturl.sort(mainurls) + -- get sorted main urls + local mainurls = localcache.cache("repository"):get("mainurls") + if not mainurls then + import("net.fasturl") + mainurls = {"https://github.com/xmake-io/xmake-repo.git", "https://gitlab.com/tboox/xmake-repo.git", "https://gitee.com/tboox/xmake-repo.git"} + fasturl.add(mainurls) + mainurls = fasturl.sort(mainurls) + localcache.cache("repository"):set("mainurls", mainurls) + localcache.cache("repository"):save() + end -- add main url if #mainurls > 0 then |
