# HG changeset patch # User Kim Alvefur # Date 1637589272 -3600 # Node ID 6f4790b8deec9b36408624bf9ff0eac1e85b0f16 # Parent 871100cdbbad8eb8b30b7aa850415b4587de1e50 mod_http_file_share: Switch to mod_cron for periodic tasks diff -r 871100cdbbad -r 6f4790b8deec plugins/mod_http_file_share.lua --- a/plugins/mod_http_file_share.lua Mon Nov 22 14:49:05 2021 +0100 +++ b/plugins/mod_http_file_share.lua Mon Nov 22 14:54:32 2021 +0100 @@ -457,7 +457,7 @@ 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 @@ 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 @@ 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 @@ summary_done(); end); - module:add_timer(1, function() - summarizer_task:run(true); - return 11 * 60 * 60; - end); end -- Reachable from the console