From 2c9331668853994d6f1c24a04e50da573c320008 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 19 Dec 2022 12:43:46 +0100 Subject: [PATCH] fix: log removal daemon now properly cleans all old logs --- src/server/log_removal.v | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/log_removal.v b/src/server/log_removal.v index a0a5f781..8e1a8c21 100644 --- a/src/server/log_removal.v +++ b/src/server/log_removal.v @@ -18,14 +18,16 @@ fn (mut app App) log_removal_daemon(schedule CronExpression) { app.linfo('Cleaning logs before $too_old_timestamp') - mut offset := u64(0) mut logs := []BuildLog{} mut counter := 0 - mut failed := 0 + mut failed := u64(0) // Remove old logs for { - logs = app.db.get_build_logs(before: too_old_timestamp, offset: offset, limit: 50) + // The offset is used to skip logs that failed to remove. Besides + // this, we don't need to move the offset, because all previously + // oldest logs will have been removed. + logs = app.db.get_build_logs(before: too_old_timestamp, offset: failed, limit: 50) for log in logs { log_file_path := os.join_path(app.conf.data_dir, logs_dir_name, log.path()) @@ -44,8 +46,6 @@ fn (mut app App) log_removal_daemon(schedule CronExpression) { if logs.len < 50 { break } - - offset += 50 } app.linfo('Cleaned $counter logs ($failed failed)')