You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-25 15:42:01 +02:00
fixed logs delete check
This commit is contained in:
@@ -1256,13 +1256,15 @@ func (app *BaseApp) initLogger() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// delete old logs
|
||||
// @todo replace with cron so that it doesn't rely on the logs write
|
||||
//
|
||||
// delete old logs (~ once 1 day)
|
||||
// ---
|
||||
logsMaxDays := app.Settings().Logs.MaxDays
|
||||
now := time.Now()
|
||||
lastLogsDeletedAt := cast.ToTime(app.Store().Get("lastLogsDeletedAt"))
|
||||
daysDiff := now.Sub(lastLogsDeletedAt).Hours() / 24
|
||||
if daysDiff >= float64(logsMaxDays) {
|
||||
if daysDiff >= 1 {
|
||||
deleteErr := app.LogsDao().DeleteOldLogs(now.AddDate(0, 0, -1*logsMaxDays))
|
||||
if deleteErr == nil {
|
||||
app.Store().Set("lastLogsDeletedAt", now)
|
||||
|
||||
Reference in New Issue
Block a user