diff options
| author | ruki <[email protected]> | 2022-05-21 11:10:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-21 11:10:44 +0800 |
| commit | 6eb2c52ef4085dfe1244b2b9f23bdc3a8e52ec28 (patch) | |
| tree | bb7506c68b0a30712ef18fed1e87fe84e59e7e9f /xmake/modules/private/service/remote_cache/client.lua | |
| parent | 51fd55be6e12e87add7dce302a1abf1eff047344 (diff) | |
improve is_connected
Diffstat (limited to 'xmake/modules/private/service/remote_cache/client.lua')
| -rw-r--r-- | xmake/modules/private/service/remote_cache/client.lua | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/xmake/modules/private/service/remote_cache/client.lua b/xmake/modules/private/service/remote_cache/client.lua index 33f6ee886..a28927b33 100644 --- a/xmake/modules/private/service/remote_cache/client.lua +++ b/xmake/modules/private/service/remote_cache/client.lua @@ -371,22 +371,30 @@ end -- is connected? we cannot depend on client:init when run action function is_connected() - -- the current process is in service? we cannot enable it - if os.getenv("XMAKE_IN_SERVICE") then - return false - end - local projectdir = os.projectdir() - local projectfile = os.projectfile() - if projectfile and os.isfile(projectfile) and projectdir then - local workdir = path.join(project_config.directory(), "remote_cache") - local statusfile = path.join(workdir, "status.txt") - if os.isfile(statusfile) then - local status = io.load(statusfile) - if status and status.connected then - return true + local connected = _g.connected + if connected == nil then + -- the current process is in service? we cannot enable it + if os.getenv("XMAKE_IN_SERVICE") then + connected = false + end + if connected == nil then + local projectdir = os.projectdir() + local projectfile = os.projectfile() + if projectfile and os.isfile(projectfile) and projectdir then + local workdir = path.join(project_config.directory(), "remote_cache") + local statusfile = path.join(workdir, "status.txt") + if os.isfile(statusfile) then + local status = io.load(statusfile) + if status and status.connected then + connected = true + end + end end end + connected = connected or false + _g.connected = connected end + return connected end -- new a client instance |
