From 933d25a65c8844cf102662e00a56c38c2b722be3 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sat, 14 Jan 2023 22:37:10 +0100 Subject: [PATCH] fix(cron): wrong * parse --- src/cron/c/parse.c | 13 ++++++++----- src/server/log_removal.v | 2 +- vieter.toml | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cron/c/parse.c b/src/cron/c/parse.c index 49253bc..c536237 100644 --- a/src/cron/c/parse.c +++ b/src/cron/c/parse.c @@ -63,16 +63,19 @@ cron_parse_error ce_parse_range(uint64_t *out, char *s, uint8_t min, uint8_t max } // Parse the three possible numbers in the pattern - uint8_t start = min; + uint8_t start; uint8_t end = max; - uint8_t interval = 1; + uint8_t interval = 0; - // * simply sets start as min and end as max - if (!(s[0] == '*' && strlen(s) == 1)) { + if (s[0] == '*' && strlen(s) == 1) { + start = min; + interval = 1; + }else { SAFE_ATOI(start, s, min, max); if (dash_index > 0) { SAFE_ATOI(end, &s[dash_index + 1], min, max); + interval = 1; } } @@ -80,7 +83,7 @@ cron_parse_error ce_parse_range(uint64_t *out, char *s, uint8_t min, uint8_t max SAFE_ATOI(interval, &s[slash_index + 1], 1, max - min); } - if (dash_index == 0 && slash_index == 0) { + if (interval == 0) { *out |= ((uint64_t) 1) << (start - min); } else { while (start <= end) { diff --git a/src/server/log_removal.v b/src/server/log_removal.v index 7f1cfb5..27dc0db 100644 --- a/src/server/log_removal.v +++ b/src/server/log_removal.v @@ -8,7 +8,7 @@ import cron const fallback_log_removal_frequency = 24 * time.hour // log_removal_daemon removes old build logs every `log_removal_frequency`. -fn (mut app App) log_removal_daemon(schedule cron.Expression) { +fn (mut app App) log_removal_daemon(schedule &cron.Expression) { for { mut too_old_timestamp := time.now().add_days(-app.conf.max_log_age) diff --git a/vieter.toml b/vieter.toml index 7744a56..34b4f4e 100644 --- a/vieter.toml +++ b/vieter.toml @@ -13,4 +13,5 @@ api_update_frequency = 2 image_rebuild_frequency = 1 max_concurrent_builds = 3 # max_log_age = 64 +log_removal_schedule = '* * *' collect_metrics = true