Skip to content

fix(scoop-cache): Delete each cached file only once - #6773

Merged
niheaven merged 4 commits into
ScoopInstaller:developfrom
candygoogy:fix/cache-rm-delete-once
Nov 10, 2026
Merged

niheaven merged 4 commits into
ScoopInstaller:developfrom
candygoogy:fix/cache-rm-delete-once

Conversation

@candygoogy

@candygoogy candygoogy commented Oct 6, 2026 •

Copy link
Copy Markdown

Description

scoop cache rm now deletes every file exactly once. For scoop cache rm <app>, the list of files to delete now also includes <app>.txt, the aria2 input file left by an interrupted download, and the separate delete of <app>.txt after each download file is removed. With */--all, all files in the cache were already in the list. App names are escaped before they are used in the match, so the dot in foo.bar doesn't match another app's fooXbar.txt.

Motivation and Context

scoop cache rm * lists all cache files, <app>.txt included, and then also deleted <app>.txt after each download file of that app. When the download file was listed first, <app>.txt was deleted twice and the second Remove-Item threw "Cannot find path". The order of the files decides whether it happens, which is why it's intermittent: in my tests Windows PowerShell 5.1 listed <app>#... first (error), PowerShell 7 listed <app>.txt first (no error).

Side effects of matching <app>.txt directly: scoop cache rm <app> now shows <app>.txt in its output and counts it, and it also removes a leftover <app>.txt when no download file of the app is left (it was kept before).

Closes #6727

How Has This Been Tested?

On Windows 11 with SCOOP, SCOOP_CACHE and XDG_CONFIG_HOME pointing to a test folder, in Windows PowerShell 5.1 and PowerShell 7, with the cache files demo#1.0#abc.zip_, demo.txt, demo2#3.0#ghi.zip, demo2.txt and other#2.0#def.zip:

Command Before After
scoop cache rm --all 5.1: "Cannot find path" for demo.txt and demo2.txt all 5 files deleted, no errors
scoop cache rm demo deletes demo.txt without listing it, "Deleted: 1 file" lists both files, "Deleted: 2 files"; demo2* and other* are kept
scoop cache rm demo other "Deleted: 2 files" "Deleted: 3 files"; demo2* is kept
scoop cache rm demo with only demo.txt left demo.txt is kept demo.txt is deleted

Added test/Scoop-Cache.Tests.ps1 with tests for --all with leftover aria2 input files, removing a single app, a leftover <app>.txt without a download, and an app name with a dot. Each of them fails without its part of the fix (in Windows PowerShell 5.1, the --all test fails with the error from the issue).

./test/bin/test.ps1 gives the same results as on develop in both shells apart from the new tests: 165 passed, and the 19 failures are the Decompression tests, which need 7-Zip, lessmsi and innounp locally. The linter passes.

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

Updates scoop cache rm to select downloads and leftover aria2 input files together, then delete each selected file once.

  • Cache removal now deletes each selected file only once.
  • Cache names with punctuation now match the app exactly.

Reviews (5) · Last reviewed commit: "fix(scoop-cache): Handle cache file name..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 448eebc9-ab97-4ddd-8221-4e1f0a531a21
📥 Commits

Reviewing files that changed from the base of the PR and between 2c6aaef and 5caec6b.

📒 Files selected for processing (2)
  • libexec/scoop-cache.ps1
  • test/Scoop-Cache.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • libexec/scoop-cache.ps1

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


Summary by CodeRabbit

  • Bug Fixes
    • Fixed app-specific cache removal so each matching cache file, including its aria2 input file, is removed only once.

Walkthrough

App-specific cache removal now selects matching cache files and aria2 input files, then removes each selected file directly. Tests cover bulk and app-specific removal. The Unreleased changelog records the fix.

Changes

Cache removal

Layer / File(s) Summary
Select and remove matching files
libexec/scoop-cache.ps1, test/Scoop-Cache.Tests.ps1, CHANGELOG.md
cacheremove escapes app names for matching and removes selected cache files and aria2 input files directly. Tests cover bulk removal, app-specific removal, leftover input files, and literal app-name matching. The changelog records the fix.

Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 5caec

App-specific and bulk cache removal now include the intended files without the former duplicate input-file deletion path. The inspected tests cover these cases, and no merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #6727 requires scoop cache rm * to delete each cache file once without a missing-path error. cacheremove now selects cache entries and removes each selected entry once. App-specific selectio…
Out of Scope Changes check ✅ Passed The libexec/scoop-cache.ps1 change and its tests implement the cache-removal fix in issue #6727. The changelog entry documents that fix. No unrelated changes appear in the whole-PR diff.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Title check ✅ Passed The title clearly summarizes the main change: preventing cached files from being deleted more than once.
Description check ✅ Passed The description explains the cache-removal change, its motivation, testing, and related issue. It is relevant to the changeset.
  • Autopilot · 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.

Comment thread libexec/scoop-cache.ps1 Resolved
Comment thread libexec/scoop-cache.ps1 Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4dee1de7-6cda-458e-a4d7-fe5d8585d3b4
📥 Commits

Reviewing files that changed from the base of the PR and between c2d56bf and 2c6aaef.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • libexec/scoop-cache.ps1

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

Comment thread libexec/scoop-cache.ps1 Resolved
@candygoogy

Copy link
Copy Markdown
Author

Escaped the app names, so scoop cache rm foo.bar no longer matches another app's fooXbar.txt (download files of such apps could already be matched before this PR). Also added test/Scoop-Cache.Tests.ps1, covering --all with leftover aria2 input files, a single app, a leftover .txt without a download, and an app name with a dot.

@candygoogy
candygoogy force-pushed the fix/cache-rm-delete-once branch from 5caec6b to 58e7ebf Compare October 18, 2026 07:17
`scoop cache rm *` lists every file in the cache, including the aria2
input file `<app>.txt` left by an interrupted download, and also deleted
`<app>.txt` after each download file of that app. When the download file
came first, `<app>.txt` was deleted twice and the second Remove-Item
failed.

Include `<app>.txt` in the list of files to delete instead, so that each
file is deleted exactly once.
@candygoogy
candygoogy force-pushed the fix/cache-rm-delete-once branch from 58e7ebf to 1a7da96 Compare November 8, 2026 08:49
@niheaven
niheaven merged commit 2be9952 into ScoopInstaller:develop Nov 10, 2026
3 checks passed
@candygoogy
candygoogy deleted the fix/cache-rm-delete-once branch November 10, 2026 16:25
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.

2 participants