From a70a8c4ffce9d970cf5611a2a32c2434df01d4ae Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Nov 2021 14:54:32 +0100 Subject: mod_http_file_share: Switch to mod_cron for periodic tasks --- plugins/mod_http_file_share.lua | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index a5ac287c..5f3c8e5e 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -457,7 +457,7 @@ if expiry >= 0 and not external_base_url then local prune_start = module:measure("prune", "times"); - local reaper_task = async.runner(function(boundary_time) + module:daily("Remove expired files", function(_, boundary_time) local prune_done = prune_start(); local iter, total = assert(uploads:find(nil, {["end"] = boundary_time; total = true})); @@ -468,8 +468,10 @@ if expiry >= 0 and not external_base_url then end module:log("info", "Pruning expired files uploaded earlier than %s", dt.datetime(boundary_time)); - if total_storage_limit then + if total_storage_usage then module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); + elseif total_storage_limit then + module:log("debug", "Global quota %s / %s", "not yet calculated", B(total_storage_limit)); end local obsolete_uploads = array(); @@ -533,19 +535,12 @@ if expiry >= 0 and not external_base_url then prune_done(); end); - - module:add_timer(5, function () - reaper_task:run(os.time()-expiry); - return 60*60; - end); end if total_storage_limit then - local async = require "util.async"; - local summary_start = module:measure("summary", "times"); - local summarizer_task = async.runner(function() + module:daily("Global quota check", function() local summary_done = summary_start(); local iter = assert(uploads:find(nil)); @@ -561,10 +556,6 @@ if total_storage_limit then summary_done(); end); - module:add_timer(1, function() - summarizer_task:run(true); - return 11 * 60 * 60; - end); end -- Reachable from the console -- cgit v1.2.3