diff options
| author | ruki <[email protected]> | 2022-05-21 13:05:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-21 13:05:21 +0800 |
| commit | 75b7205643d9846f6233250e1189c41251821674 (patch) | |
| tree | c8a36ba24370cc10699516db699eaa1320e4b664 | |
| parent | 4a858cc597b62dddd4e21d55460bf888e03f3cef (diff) | |
clean remote cache
5 files changed, 23 insertions, 15 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index 17020497d..96d777c1b 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -22,6 +22,7 @@ import("core.base.bytes") import("core.base.hashset") import("core.project.config") +import("private.service.client_config") import("private.service.remote_cache.client", {alias = "remote_cache_client"}) -- is enabled? @@ -75,6 +76,10 @@ end -- clean cached files function clean() os.rm(rootdir()) + if remote_cache_client.is_connected() then + client_config.load() + remote_cache_client.singleton():clean() + end end -- get hit rate diff --git a/xmake/modules/private/service/client_config.lua b/xmake/modules/private/service/client_config.lua index 156576fcf..b65ef8d13 100644 --- a/xmake/modules/private/service/client_config.lua +++ b/xmake/modules/private/service/client_config.lua @@ -89,13 +89,14 @@ end -- load configs function load() - assert(not _g.configs, "config has been loaded!") - local filepath = configfile() - if not os.isfile(filepath) then - _generate_configfile() + if _g.configs == nil then + local filepath = configfile() + if not os.isfile(filepath) then + _generate_configfile() + end + assert(os.isfile(filepath), "%s not found!", filepath) + _g.configs = io.load(filepath) end - assert(os.isfile(filepath), "%s not found!", filepath) - _g.configs = io.load(filepath) end -- save configs diff --git a/xmake/modules/private/service/remote_cache/client.lua b/xmake/modules/private/service/remote_cache/client.lua index 9a8ce7b59..98b715a68 100644 --- a/xmake/modules/private/service/remote_cache/client.lua +++ b/xmake/modules/private/service/remote_cache/client.lua @@ -277,7 +277,7 @@ function remote_cache_client:clean() assert(self:is_connected(), "%s: has been not connected!", self) local addr = self:addr() local port = self:port() - local sock = assert(socket.connect(addr, port), "%s: server unreachable!", self) + local sock = assert(self:_sock_open(), "open socket failed!") local session_id = self:session_id() local errors local ok = false @@ -294,6 +294,7 @@ function remote_cache_client:clean() end end end + self:_sock_close(sock) if ok then print("%s: clean files ok!", self) else diff --git a/xmake/modules/private/service/remote_cache/server_session.lua b/xmake/modules/private/service/remote_cache/server_session.lua index 9437ccfb3..5a68877e6 100644 --- a/xmake/modules/private/service/remote_cache/server_session.lua +++ b/xmake/modules/private/service/remote_cache/server_session.lua @@ -120,8 +120,8 @@ end -- clean files function server_session:clean() - vprint("%s: clean files in %s ..", self, self:workdir()) - os.tryrm(self:workdir()) + vprint("%s: clean files in %s ..", self, self:cachedir()) + os.tryrm(self:cachedir()) vprint("%s: clean files ok", self) end diff --git a/xmake/modules/private/service/server_config.lua b/xmake/modules/private/service/server_config.lua index a024c731c..ca007e8d7 100644 --- a/xmake/modules/private/service/server_config.lua +++ b/xmake/modules/private/service/server_config.lua @@ -91,13 +91,14 @@ end -- load configs function load() - assert(not _g.configs, "config has been loaded!") - local filepath = configfile() - if not os.isfile(filepath) then - _generate_configfile() + if _g.configs == nil then + local filepath = configfile() + if not os.isfile(filepath) then + _generate_configfile() + end + assert(os.isfile(filepath), "%s not found!", filepath) + _g.configs = io.load(filepath) end - assert(os.isfile(filepath), "%s not found!", filepath) - _g.configs = io.load(filepath) end -- save configs |
