Skip to content

Prune stale log-retention index entries before enforcing max_log_files #12

Description

@codeforester

Problem

The .base-cli-log-index.json can contain paths for log files that no longer exist. prune_log_files() currently counts those stale entries when calculating excess_count, which can delete more real log files than max_log_files permits.

A concrete reproduction with three real logs, one phantom index entry, and max_log_files=3 deletes two real logs instead of one.

Scope

  • Filter indexed paths to existing files before building pruning candidates and calculating excess_count.
  • Keep the current log file eligible for retention even before it exists on disk.
  • Add a regression test covering a stale/phantom index entry and asserting the configured real-file limit.

Acceptance criteria

  • Stale index entries never consume a retention slot.
  • Pruning leaves at most the requested number of real log files, including the current log.
  • Existing index-based retention behavior remains covered.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions