Skip to content

[BUG] cortex logs --clear removes any old file in the logs directory instead of only .log and .txt log files #51691

Description

@prinws-11

Project

cortex

Description

The normal cortex logs view only treats .log and .txt files as logs, but cortex logs --clear deletes every old file in the logs directory with no extension filtering at all. This means sidecar files or unrelated artifacts stored there can be removed even though the command is documented as clearing old log files.

Error Message

Debug Logs

System Information

OS: Windows 10
RAM: 16 GB
CPU: Intel(R) Core(TM) i7-1165G7 @ 2.8GHz(8 CPUs), ~2.8GH

Screenshots

https://github.com/prinws-11/SN_100_MEDIA_Evidence/blob/main/image5.png

Steps to Reproduce

  1. Place an old non-log file in the Cortex logs directory, such as notes.json or snapshot.bin.
  2. Make sure its modified time is older than the selected retention window.
  3. Run cortex logs --clear.
  4. Inspect the logs directory afterward.

Expected Behavior

cortex logs --clear should only delete old log files, consistent with the main command’s .log / .txt filtering and the help text.

Actual Behavior

The clear path deletes any old file in the logs directory, regardless of whether it is actually a log file.

Additional Context

src/cortex-cli/src/logs_cmd.rs:41

  • Help text says Clear old log files.
    src/cortex-cli/src/logs_cmd.rs:116-121
  • The normal log-file discovery path only includes files whose names end with .log or .txt.
    src/cortex-cli/src/logs_cmd.rs:316-336
  • run_clear() iterates every file in logs_dir and deletes it if modified < cutoff_time, with no extension filter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideIssues related to IDEvalidValid issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions