Conversation
Under sandboxed environments like Flatpak (and some filesystems), QFileInfo::birthTime() reports epoch 0 or is invalid, so every log looked decades old and the default DeleteDays strategy deleted all of them on connect. Fall back to lastModified() when the birth time is missing or before 1980. Also fix DeleteSize: the cumulative-size loop iterated oldest-first, so once the limit was reached it deleted the *newest* logs and kept the oldest. Sort newest-first so recent logs survive. The selection policy is extracted into log_cleanup::selectLogsToDelete (src/logger/LogCleanup.*) so it can be unit tested without a filesystem, and a new TestAutoLogger covers both bugs against the real implementation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJWFydUn7wirdvQttfamkA
Prune older logs only once the total exceeds the limit (a total of exactly N MB is kept), and never delete the newest log, so a single oversized log cannot wipe out the whole directory. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJWFydUn7wirdvQttfamkA
Reviewer's GuideThe PR extracts AutoLogger retention decisions into a testable cleanup module, uses a validated birth-time/last-modified fallback, and sorts logs newest-first so date and size policies delete the intended older files. New tests cover timestamp edge cases, retention boundaries, ordering, cumulative size behavior, and real filesystem timestamps. Sequence diagram for robust log timestamp selectionsequenceDiagram
participant AutoLogger
participant QFileInfo
participant LogCleanup
AutoLogger->>QFileInfo: birthTime()
LogCleanup->>LogCleanup: Validate birth timestamp
alt valid birth time after epoch cutoff
LogCleanup-->>AutoLogger: birth time
else invalid or unreliable birth time
AutoLogger->>QFileInfo: lastModified()
LogCleanup-->>AutoLogger: last-modified time
end
Flow diagram for AutoLogger cleanup selectionflowchart TD
A[AutoLogger.deleteOldLogs] --> B[QDir entryInfoList]
B --> C[getFileTime]
C --> D[selectLogsToDelete]
D --> E{Cleanup strategy}
E -->|KeepForever| F[Return no files]
E -->|DeleteDays| G[Delete logs at or beyond day threshold]
E -->|DeleteSize| H[Retain newest logs within size limit]
G --> I[Return selected files]
H --> I
I --> J[Remove selected files]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #554 +/- ##
==========================================
+ Coverage 27.11% 27.24% +0.13%
==========================================
Files 557 559 +2
Lines 45812 45893 +81
Branches 4876 4879 +3
==========================================
+ Hits 12421 12505 +84
+ Misses 33391 33388 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix AutoLogger log retention to use a robust file timestamp helper and correct log ordering for cleanup strategies.
Enhancements:
Tests:
Summary by Sourcery
Fix AutoLogger retention decisions by using reliable file times and preserving newer logs during cleanup.
Bug Fixes:
Enhancements:
Build:
Tests: