From 12e3795a830bfce28a59678ab343a93f634de1d8 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 13 Jun 2020 04:00:15 +0100 Subject: [PATCH] cron: permit entry.schedule() to reuse existing --- app/modules/cron.c | 11 +++++++---- docs/modules/cron.md | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/modules/cron.c b/app/modules/cron.c index 2b528ebf7f..4688b70f85 100644 --- a/app/modules/cron.c +++ b/app/modules/cron.c @@ -136,10 +136,13 @@ static size_t lcron_findindex(lua_State *L, cronent_ud_t *ud) { static int lcron_schedule(lua_State *L) { cronent_ud_t *ud = luaL_checkudata(L, 1, "cron.entry"); - char *strdesc = (char*)luaL_checkstring(L, 2); - struct cronent_desc desc; - lcron_parsedesc(L, strdesc, &desc); - ud->desc = desc; + char *strdesc = (char*)luaL_optstring(L, 2, NULL); + + if (strdesc != NULL) { + struct cronent_desc desc; + lcron_parsedesc(L, strdesc, &desc); + ud->desc = desc; + } size_t i = lcron_findindex(L, ud); diff --git a/docs/modules/cron.md b/docs/modules/cron.md index 09c2fe91e8..9568cdee04 100644 --- a/docs/modules/cron.md +++ b/docs/modules/cron.md @@ -83,10 +83,10 @@ end) ## cron.entry:schedule() -Sets a new schedule mask. +Sets a new schedule mask and/or restores an unscheduled entry. #### Syntax -`schedule(mask)` +`schedule([mask])` #### Parameters - `mask` - [crontab](https://en.wikipedia.org/wiki/Cron#Overview)-like string mask for schedule