mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-14 18:18:14 +02:00
updated logs delete trigger frequency and tests
This commit is contained in:
1 parent
b0f8c78022
commit
1f08b70283
2 files changed
+5
-7
No files matched your search
+3
-5
@@ -1258,14 +1258,12 @@ func (app *BaseApp) initLogger() error {
|
||||
|
||||
// @todo replace with cron so that it doesn't rely on the logs write
|
||||
//
|
||||
// delete old logs (~ once 1 day)
|
||||
// delete old logs (~ twice a day)
|
||||
// ---
|
||||
logsMaxDays := app.Settings().Logs.MaxDays
|
||||
now := time.Now()
|
||||
lastLogsDeletedAt := cast.ToTime(app.Store().Get("lastLogsDeletedAt"))
|
||||
daysDiff := now.Sub(lastLogsDeletedAt).Hours() / 24
|
||||
if daysDiff >= 1 {
|
||||
deleteErr := app.LogsDao().DeleteOldLogs(now.AddDate(0, 0, -1*logsMaxDays))
|
||||
if now.Sub(lastLogsDeletedAt).Hours() >= 6 {
|
||||
deleteErr := app.LogsDao().DeleteOldLogs(now.AddDate(0, 0, -1*app.Settings().Logs.MaxDays))
|
||||
if deleteErr == nil {
|
||||
app.Store().Set("lastLogsDeletedAt", now)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user