--- a/.luacheckrc Fri Dec 03 09:01:09 2021 +0100
+++ b/.luacheckrc Fri Dec 03 09:05:41 2021 +0100
@@ -52,6 +52,7 @@
"module.add_identity",
"module.add_item",
"module.add_timer",
+ "module.weekly",
"module.daily",
"module.hourly",
"module.broadcast",
--- a/core/moduleapi.lua Fri Dec 03 09:01:09 2021 +0100
+++ b/core/moduleapi.lua Fri Dec 03 09:05:41 2021 +0100
@@ -521,6 +521,11 @@
self:cron({ name = name; when = "daily"; run = fun });
end
+function api:weekly(name, fun)
+ if type(name) == "function" then fun, name = name, nil; end
+ self:cron({ name = name; when = "weekly"; run = fun });
+end
+
local path_sep = package.config:sub(1,1);
function api:get_directory()
return self.resource_path or self.path and (self.path:gsub("%"..path_sep.."[^"..path_sep.."]*$", "")) or nil;
--- a/plugins/mod_cron.lua Fri Dec 03 09:01:09 2021 +0100
+++ b/plugins/mod_cron.lua Fri Dec 03 09:05:41 2021 +0100
@@ -3,7 +3,7 @@
local async = require("util.async");
local datetime = require("util.datetime");
-local periods = { hourly = 3600; daily = 86400 }
+local periods = { hourly = 3600; daily = 86400; weekly = 7 * 86400 }
local active_hosts = {}
--- a/teal-src/plugins/mod_cron.tl Fri Dec 03 09:01:09 2021 +0100
+++ b/teal-src/plugins/mod_cron.tl Fri Dec 03 09:05:41 2021 +0100
@@ -12,6 +12,7 @@
local enum frequency
"hourly"
"daily"
+ "weekly"
end
local record task_spec
@@ -28,7 +29,7 @@
item : task_spec
end
-local periods : { frequency : integer } = { hourly = 3600, daily = 86400 }
+local periods : { frequency : integer } = { hourly = 3600, daily = 86400, weekly = 7*86400 }
local active_hosts : { string : boolean } = { }