Skip to content

feat(cli): add cleanup downloads command - #8015

Merged
viceice merged 1 commit into
viceice/refactor/cache-evictionfrom
viceice/feat/cleanup-downloads
Oct 27, 2026
Merged

viceice merged 1 commit into
viceice/refactor/cache-evictionfrom
viceice/feat/cleanup-downloads

Conversation

@viceice

@viceice viceice commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Changes

  • New containerbase-cli cleanup downloads [--dry-run] command.
  • Evicts the oldest files from the download cache (CONTAINERBASE_CACHE_DIR) until the fill level is below CONTAINERBASE_MAX_ALLOCATED_DISK, like install-tool does after each install.
  • A dry run logs the file it would start with.
  • Part of feature request: Integrate cleanup into the install-tool #4362.

Context

Please select one of the following:

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Code, tests and docs by Claude Code (Claude Opus 5.5), reviewed by @viceice.

Use of AI in replying to PR comments

Who answers review comments:

  • @viceice will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted. Name the account.
  • An agent will draft replies and reply autonomously. This is heavily discouraged, and we prefer that there are humans in the loop
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified tests

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a cleanup downloads command to remove older cached downloads when disk usage exceeds the configured limit.
    • Added a --dry-run option to preview the oldest file without deleting it. The cleanup threshold defaults to 100%, and cleanup does nothing when the cache directory is not configured.
  • Documentation
    • Documented the new command, its disk-usage behavior, and the dry-run option.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c986293-25ab-4651-8334-626e087cbf5a
Commits

Reviewing files that changed from the base of the PR and between 28ceac5 and 28154aa.

Files selected for processing: 6
  • docs/tools.md
  • src/cli/cleanup/index.spec.ts
  • src/cli/cleanup/index.ts
  • src/cli/command/cleanup-downloads.spec.ts
  • src/cli/command/cleanup-downloads.ts
  • src/cli/command/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The pull request adds a cleanup downloads CLI command. It calls cache eviction with an optional dry-run flag, reports the result, and returns a success or failure code.

Changes: Download cache cleanup

Layer / File(s) Summary
Eviction wrapper and documented behavior
src/cli/cleanup/index.ts, src/cli/cleanup/index.spec.ts, docs/tools.md
cleanupDownloads calls CacheService.evict and returns the evicted paths. It logs when there is nothing to evict and logs the removal count only outside dry-run mode. Documentation describes the cache directory, disk threshold, and dry-run behavior.
CLI command registration and execution
src/cli/command/cleanup-downloads.ts, src/cli/command/index.ts, src/cli/command/cleanup-downloads.spec.ts
The command passes its dry-run option to cleanupDownloads, logs the outcome and elapsed time, and returns 0 or 1. Tests cover successful execution, dry run, and failures.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CleanupDownloadsCommand
  participant cleanupDownloads
  participant CacheService
  User->>CleanupDownloadsCommand: run cleanup downloads
  CleanupDownloadsCommand->>cleanupDownloads: pass dry-run flag
  cleanupDownloads->>CacheService: evict(dryRun)
  CacheService-->>cleanupDownloads: return evicted paths
  cleanupDownloads-->>CleanupDownloadsCommand: return paths
  CleanupDownloadsCommand-->>User: report outcome and exit code
Loading

Possibly related issues

  • containerbase/base#8013: The PR adds the cleanup downloads subcommand, but not the aggregate command that runs all three cleanup subcommands.
  • containerbase/base#8027: The PR adds oldest-file eviction. The cache-hit mtime update requested by this issue is not included.
Merge Risk: Minimal · up to 28154

The cleanup command appears ready to merge after normal checks; no blocking issue was identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding the cleanup downloads CLI command.
Linked Issues check Passed Issue #8012 requires a cleanup downloads command that evicts the oldest files from CONTAINERBASE_CACHE_DIR until usage is below CONTAINERBASE_MAX_ALLOCATED_DISK. The new command is registered at…
Out of Scope Changes check Passed The changes stay within issue #8012. The command implementation, command registration, documentation, and automated tests directly support the cleanup command and its --dry-run option. No unrelated …
Full details: Linked Issues check

Explanation

Issue #8012 requires a cleanup downloads command that evicts the oldest files from CONTAINERBASE_CACHE_DIR until usage is below CONTAINERBASE_MAX_ALLOCATED_DISK. The new command is registered at cleanup downloads. cleanupDownloads() calls CacheService.evict(dryRun), which provides the required cache eviction behavior. The implementation includes automated tests for cleanup, dry-run forwarding, and failure handling.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #8012. The command implementation, command registration, documentation, and automated tests directly support the cleanup command and its --dry-run option. No unrelated change is shown.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@viceice
viceice added this pull request to stack #8019 October 26, 2026 13:05
@viceice
viceice force-pushed the viceice/feat/cleanup-downloads branch from efe45c2 to a6c184c Compare October 26, 2026 13:37
@viceice
viceice force-pushed the viceice/feat/cleanup-downloads branch 2 times, most recently from b0f7b5c to 5df9a32 Compare October 26, 2026 16:15
@viceice
viceice force-pushed the viceice/feat/cleanup-downloads branch from 5df9a32 to 28154aa Compare October 26, 2026 16:59
@viceice
viceice marked this pull request as ready for review October 26, 2026 17:05
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@viceice
viceice enabled stacked auto-merge October 26, 2026 17:06
Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
@viceice
viceice force-pushed the viceice/feat/cleanup-downloads branch from 28154aa to 1bb2fab Compare October 27, 2026 07:08
@coderabbitai coderabbitai Bot mentioned this pull request Oct 27, 2026
5 of 14 tasks
@viceice
viceice added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 6cfcc72 Oct 27, 2026
56 of 67 checks passed
@viceice
viceice deleted the viceice/feat/cleanup-downloads branch October 27, 2026 08:31
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 14.54.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup: add cleanup downloads command

1 participant