diff options
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -118,18 +118,21 @@ local function cached_xc_call(method) local path = mp_utils.join_path( script_dir, 'cache/' .. xc.server:gsub('%W', '_') .. '.' .. method) - local f = mp_utils.file_info(path) - if f and os.time() - f.mtime < 24*60*60 then - return util.read_json_file(path) + local data + + if not f or os.time() - f.mtime > 24*60*60 then + data = xc[method](xc) + if data then + util.write_json_file(path, data) + end end - local data = xc[method](xc) - if not data then - return + if f and not data then + print('using cached ' .. method) + data = util.read_json_file(path) end - util.write_json_file(path, data) return data end |
