Skip to content

#2372: Add --retention-delay option to ide cleanup - #2378

Open
krystynaShatkovska wants to merge 3 commits into
devonfw:mainfrom
krystynaShatkovska:feature/issue-2372-retention-delay
Open

#2372: Add --retention-delay option to ide cleanup#2378
krystynaShatkovska wants to merge 3 commits into
devonfw:mainfrom
krystynaShatkovska:feature/issue-2372-retention-delay

Conversation

@krystynaShatkovska

@krystynaShatkovska krystynaShatkovska commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #2372

Implemented changes:

Adds a --retention-delay option to ide cleanup. It takes an ISO-8601 duration (e.g. P30D, PT2H30M; default 1 year) and deletes stale files (not modified within that period) in $IDE_HOME/updates, $IDE_ROOT/_ide/tmp and ~/Downloads/ide. After deletion it deletes empty folders (but keeps the scanned roots). Invalid durations are rejected with a clear error.

Testing instructions

Automated tests

Run the test class, it covers all the core cases:
mvn -pl cli test -Dtest=CleanupCommandletTest

Manual test (run against a local build of this branch, in a clean/throwaway IDE workspace)

The command scans three roots for stale files: $IDE_HOME/updates (only inside a project), $IDE_ROOT/_ide/tmp (always exists), and ~/Downloads/ide (the download cache).

a. Create a stale and a recent file in the temp folder:
New-Item -Path "$env:IDE_ROOT_ide\tmp\stale.bin" -Value "x" -Force
(Get-Item "$env:IDE_ROOT_ide\tmp\stale.bin").LastWriteTime = (Get-Date).AddDays(-31)
New-Item -Path "$env:IDE_ROOT_ide\tmp\fresh.bin" -Value "x" -Force

b. Run cleanup and answer Yes (this also uninstalls unused software — use a clean workspace):
ide cleanup --retention-delay=P30D

c. Confirm:
Test-Path "$env:IDE_ROOT_ide\tmp\stale.bin" # expected: False
Test-Path "$env:IDE_ROOT_ide\tmp\fresh.bin" # expected: True

d. Verify invalid input is rejected:
ide cleanup --retention-delay=PT6M10D # months not allowed in a time-based duration
ide cleanup --retention-delay=P0D # must be positive
ide cleanup --retention-delay=-P30D # must be positive
ide cleanup --retention-delay=abc # not ISO-8601


Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

Adds a --retention-delay option to the cleanup commandlet to delete stale
files that have not been modified within a configurable period. Files are
scanned recursively under $IDE_HOME/updates, $IDE_ROOT/_ide/tmp and
~/Downloads/ide.

The option accepts a time-based ISO-8601 duration (e.g. P30D) and defaults
to 1 year (365 days) if not provided. Empty folders left behind after
deleting stale files are removed, while the scanned roots themselves are kept.
@coveralls

coveralls commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33621501883

Coverage increased (+0.09%) to 73.704%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 9 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

9 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/commandlet/cleanup/CleanupCommandlet.java 9 91.34%

Coverage Stats

Coverage Status
Relevant Lines: 18436
Covered Lines: 14203
Line Coverage: 77.04%
Relevant Branches: 8184
Covered Branches: 5417
Branch Coverage: 66.19%
Branches in Coverage %: Yes
Coverage Strength: 3.29 hits per line

💛 - Coveralls

@krystynaShatkovska krystynaShatkovska moved this from 🆕 New to Team Review in IDEasy board Aug 27, 2026
@samuelkos17 samuelkos17 self-assigned this Aug 27, 2026

@samuelkos17 samuelkos17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the --retention-dely to the cleanup commandlet. I tried to follow your testing steps, however the commands you provided didn't work out for me. I've manually moved the files to /_ide/tmp though and then ran the cleanup command and it worked!
While reviewing I found some problems that could lead to issues and that really need to get addressed before moving this to In Review. You can find them in the Comments here.
Besides that I still have on recommendation:
documentation/tmp.adoc line 18 needs to be updated according to the new functionality.

Comment thread cli/src/main/resources/nls/Help.properties
Comment thread cli/src/main/resources/nls/Help_de.properties
Comment thread cli/src/main/resources/nls/Help_de.properties
Comment thread cli/src/main/resources/nls/Help.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

Implement --retention-delay option for ide cleanup (stale files in updates, _ide/tmp and ~/Downloads/ide)

3 participants