From 3707b0245c1952d4a7a2ba2314c552d2195fe128 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 3 Apr 2019 14:00:13 -0300 Subject: fs: separate cache_timeout and cache_fail_timeout Makes failure to search for manifest-5.4 cache for a full day. --- src/luarocks/core/cfg.lua | 5 +++-- src/luarocks/fs/lua.lua | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index c420c5bd..acda1e46 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua @@ -188,8 +188,9 @@ local function make_defaults(lua_version, target_cpu, platforms, home) hooks_enabled = true, deps_mode = "one", check_certificates = false, - - cache_timeout = 10, + + cache_timeout = 60, + cache_fail_timeout = 86400, version_check_on_fail = true, lua_modules_path = "/share/lua/"..lua_version, diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 71529cc0..22bffce0 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -779,11 +779,15 @@ local function http_request(url, filename, http, cache) if status or timestamp then local unixtime = read_timestamp(filename..".unixtime") if unixtime then - if os.time() - unixtime < cfg.cache_timeout then - if status then + local diff = os.time() - tonumber(unixtime) + if status then + if diff < cfg.cache_fail_timeout then return nil, status, {} end - return true, nil, nil, true + else + if diff < cfg.cache_timeout then + return true, nil, nil, true + end end end -- cgit v1.2.3-55-g6feb