fix(cron): wrong * parse
ci/woodpecker/pr/docs Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details
ci/woodpecker/pr/docker Pipeline was successful Details
ci/woodpecker/pr/man Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details

Jef Roosens 2023-01-14 22:37:10 +01:00
parent 58b58806f3
commit 933d25a65c
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 10 additions and 6 deletions

View File

@ -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 // Parse the three possible numbers in the pattern
uint8_t start = min; uint8_t start;
uint8_t end = max; 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); SAFE_ATOI(start, s, min, max);
if (dash_index > 0) { if (dash_index > 0) {
SAFE_ATOI(end, &s[dash_index + 1], min, max); 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); 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); *out |= ((uint64_t) 1) << (start - min);
} else { } else {
while (start <= end) { while (start <= end) {

View File

@ -8,7 +8,7 @@ import cron
const fallback_log_removal_frequency = 24 * time.hour const fallback_log_removal_frequency = 24 * time.hour
// log_removal_daemon removes old build logs every `log_removal_frequency`. // 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 { for {
mut too_old_timestamp := time.now().add_days(-app.conf.max_log_age) mut too_old_timestamp := time.now().add_days(-app.conf.max_log_age)

View File

@ -13,4 +13,5 @@ api_update_frequency = 2
image_rebuild_frequency = 1 image_rebuild_frequency = 1
max_concurrent_builds = 3 max_concurrent_builds = 3
# max_log_age = 64 # max_log_age = 64
log_removal_schedule = '* * *'
collect_metrics = true collect_metrics = true