ScoopInstaller / Scoop

A command-line installer for Windows.
https://scoop.sh
Other
21.29k stars 1.41k forks source link

[Feature] Show space saving after running `scoop cleanup` (`Deleted: xxx MB`) #5486

Open przemoc opened 1 year ago

przemoc commented 1 year ago

Feature Request

Is your feature request related to a problem? Please describe.

scoop cleanup does not show how much space was freed after running it. scoop cache rm does that.

Example:

PS C:\Users\przemoc> scoop cache rm -a
Removing https_github.com_yt-dlp_FFmpeg-Builds_releases_download_autobuild-2023-04-21-12-35_ffmpeg-n6.0-17-g8f61cbf1b9-win64-gpl-6.0.zip...
Removing https_github.com_yt-dlp_FFmpeg-Builds_releases_download_autobuild-2023-04-22-12-33_ffmpeg-n6.0-17-g8f61cbf1b9-win64-gpl-6.0.zip...
Deleted: 2 files, 250.7 MB
PS C:\Users\przemoc> scoop cleanup -a
Removing ffmpeg-yt-dlp: 6.0-17-20230420 6.0-17-20230421
Everything is shiny now!

If someone does not do scoop cleanup -a routinely, then savings can be enormous, bigger than scoop cache rm -a. Seeing numbers can make users more aware of that.

Describe the solution you'd like

After running scoop cleanup display:

Deleted: xxx MB

(Showing number of deleted files is less useful in this case and would needlessly require traversal of outdated package versions to count number of files.)

Describe alternatives you've considered

Manually checking space before and after running given command. scoop cache rm does not need that, so scoop cleanup could be also improved.

rashil2000 commented 1 year ago

Hi, would you like to work on this feature? It should be simple enough.

przemoc commented 1 year ago

I know nothing about PowerShell, but yes, I may try to implement this enhancement.

Quickly looking at it (i.e. required operation, not scoop source code yet) seems that the simplest way to get free space for given path, so that it could properly support volumes mounted in folders (junctions to \\?\Volume{...}\), is using Get-Volume -FilePath, e.g.

PS> (Get-Volume -FilePath "C:\Users\przemoc\scoop\apps").SizeRemaining
40360910848

To avoid checking space usage by each removed version and summing it up, my idea is to get .SizeRemaining at the beginning and at the end of scoop cleanup, and add message at the end Disk space saved during cleanup: xxx. Why not Deleted: xxx as originally suggested? Because there could be something else running in Windows that could change .SizeRemaining in-between, so we do not want to claim that it's scoop who deleted everything.

Does this approach sound acceptable?

rashil2000 commented 1 year ago

Hey, sorry for the delayed response, somehow this thread got buried in the huge mess of GitHub notifications.

The approach sounds good to me!

przemoc commented 10 months ago

Thanks, @rashil2000, for responding, and sorry for late reply from my side too. I hope I'll attempt working on this feature by end of the month.

rashil2000 commented 10 months ago

Sure!