[#5179] fixed days calculation for triggering old logs deletion

This commit is contained in:
Nehme Roumani 2024-07-06 12:50:21 +03:00 committed by GitHub
parent f1aa477378
commit 10ac417d96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -1261,7 +1261,7 @@ func (app *BaseApp) initLogger() error {
logsMaxDays := app.Settings().Logs.MaxDays logsMaxDays := app.Settings().Logs.MaxDays
now := time.Now() now := time.Now()
lastLogsDeletedAt := cast.ToTime(app.Store().Get("lastLogsDeletedAt")) lastLogsDeletedAt := cast.ToTime(app.Store().Get("lastLogsDeletedAt"))
daysDiff := now.Sub(lastLogsDeletedAt).Hours() * 24 daysDiff := now.Sub(lastLogsDeletedAt).Hours() / 24
if daysDiff > float64(logsMaxDays) { if daysDiff > float64(logsMaxDays) {
deleteErr := app.LogsDao().DeleteOldLogs(now.AddDate(0, 0, -1*logsMaxDays)) deleteErr := app.LogsDao().DeleteOldLogs(now.AddDate(0, 0, -1*logsMaxDays))
if deleteErr == nil { if deleteErr == nil {