Repository navigation
fix(scoop-cache): Delete each cached file only once - #6773
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
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
WalkthroughApp-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. ChangesCache removal
Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to 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)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4dee1de7-6cda-458e-a4d7-fe5d8585d3b4
📒 Files selected for processing (2)
CHANGELOG.mdlibexec/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.
|
Escaped the app names, so |
5caec6b to
58e7ebf
Compare
`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.
58e7ebf to
1a7da96
Compare
Description
scoop cache rmnow deletes every file exactly once. Forscoop 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>.txtafter 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 infoo.bardoesn't match another app'sfooXbar.txt.Motivation and Context
scoop cache rm *lists all cache files,<app>.txtincluded, and then also deleted<app>.txtafter each download file of that app. When the download file was listed first,<app>.txtwas deleted twice and the secondRemove-Itemthrew "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>.txtfirst (no error).Side effects of matching
<app>.txtdirectly:scoop cache rm <app>now shows<app>.txtin its output and counts it, and it also removes a leftover<app>.txtwhen 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_CACHEandXDG_CONFIG_HOMEpointing to a test folder, in Windows PowerShell 5.1 and PowerShell 7, with the cache filesdemo#1.0#abc.zip_,demo.txt,demo2#3.0#ghi.zip,demo2.txtandother#2.0#def.zip:scoop cache rm --alldemo.txtanddemo2.txtscoop cache rm demodemo.txtwithout listing it, "Deleted: 1 file"demo2*andother*are keptscoop cache rm demo otherdemo2*is keptscoop cache rm demowith onlydemo.txtleftdemo.txtis keptdemo.txtis deletedAdded
test/Scoop-Cache.Tests.ps1with tests for--allwith leftover aria2 input files, removing a single app, a leftover<app>.txtwithout 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--alltest fails with the error from the issue)../test/bin/test.ps1gives the same results as ondevelopin 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:
developbranch.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
Updates
scoop cache rmto select downloads and leftover aria2 input files together, then delete each selected file once.Reviews (5) · Last reviewed commit: "fix(scoop-cache): Handle cache file name..." · Reviewed by Greptile