[PR #5015] Fix log purging #4396

Open
opened 2026-04-25 00:19:35 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/5015
Author: @sir-wilhelm
Created: 1/29/2026
Status: 🔄 Open

Base: masterHead: log-purge-fixes


📝 Commits (4)

  • 8f8acc2 Added scanner log purging.
  • ead270a Purge daily logs folder whenever a new one is created.
  • f069475 Move scanner log purge into the LogManager.
  • f819d66 If scanLogsToKeep is <= 0 don't purge.

📊 Changes

2 files changed (+60 additions, -18 deletions)

View changed files

📝 server/managers/LogManager.js (+57 -13)
📝 server/scanner/LibraryScan.js (+3 -5)

📄 Description

Brief summary

Scanner logs are never purged (despite there being a server setting for it).
Daily logs purge on startup (w/ a potential off by one error if you start the server on a new day), and the continuous purging does not work, since new logs were never tracked in dailyLogFiles.

Which issue is fixed?

No issue, this was brought up in discord.
https://discord.com/channels/942908292873723984/942914154254176257/1465893426049323103

In-depth Description

Two commits, one for adding Scanner log purging and another for fixing the daily log purging.

LibraryScan/scanner changes:
The Scanner makes sure the scanLogDir is created, but so does the LogManager. They both don't need to, but I did not want to decide where that logic should reside, so I left it in both places.
I added a purge scanner logs function/call after each scan is complete.

Note: the default is 2, and scanner logs have never been purged, so there could be quite a bit of clean up once this hits prod instances.

LogManager/daily log changes:
extracted a common function to do the purging/apply the log retention.
I call the function after daily logs are created and on startup.
dailyLogFiles now tracks when new files are created (so they can be purged).

How have you tested this?

Dev instance. I tested having extra logs on start up and rolling over to a new day to test daily purging. Running scans to make sure those are purging was also tested.

Screenshots

n/a


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/5015 **Author:** [@sir-wilhelm](https://github.com/sir-wilhelm) **Created:** 1/29/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `log-purge-fixes` --- ### 📝 Commits (4) - [`8f8acc2`](https://github.com/advplyr/audiobookshelf/commit/8f8acc2271c903c5fe9bbe669c8ed1da4bd23638) Added scanner log purging. - [`ead270a`](https://github.com/advplyr/audiobookshelf/commit/ead270abbe3048ef6626ce1703d11e58303c44a0) Purge daily logs folder whenever a new one is created. - [`f069475`](https://github.com/advplyr/audiobookshelf/commit/f069475a4e0b88da853df9663a9d8b2f803bcf77) Move scanner log purge into the LogManager. - [`f819d66`](https://github.com/advplyr/audiobookshelf/commit/f819d661e86957b15d4f1741deb62c78f4fe4ede) If scanLogsToKeep is <= 0 don't purge. ### 📊 Changes **2 files changed** (+60 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `server/managers/LogManager.js` (+57 -13) 📝 `server/scanner/LibraryScan.js` (+3 -5) </details> ### 📄 Description ## Brief summary Scanner logs are never purged (despite there being a server setting for it). Daily logs purge on startup (w/ a potential off by one error if you start the server on a new day), and the continuous purging does not work, since new logs were never tracked in `dailyLogFiles`. ## Which issue is fixed? No issue, this was brought up in discord. https://discord.com/channels/942908292873723984/942914154254176257/1465893426049323103 ## In-depth Description Two commits, one for adding Scanner log purging and another for fixing the daily log purging. LibraryScan/scanner changes: The Scanner makes sure the `scanLogDir` is created, but so does the `LogManager`. They both don't _need_ to, but I did not want to decide where that logic should reside, so I left it in both places. I added a purge scanner logs function/call after each scan is complete. **Note**: the default is 2, and scanner logs have never been purged, so there could be quite a bit of clean up once this hits prod instances. LogManager/daily log changes: extracted a common function to do the purging/apply the log retention. I call the function after daily logs are created and on startup. `dailyLogFiles` now tracks when new files are created (so they can be purged). ## How have you tested this? Dev instance. I tested having extra logs on start up and rolling over to a new day to test daily purging. Running scans to make sure those are purging was also tested. ## Screenshots n/a --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:35 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4396