diff options
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 |
