Skip to content

Commit

Permalink
cron: permit entry.schedule() to reuse existing
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf committed Jun 13, 2020
1 parent 2e61026 commit 12e3795
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions app/modules/cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions docs/modules/cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 12e3795

Please sign in to comment.