Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scoop-info): Show app installed/download size #4886

Merged
merged 20 commits into from
Jun 21, 2022

Conversation

tech189
Copy link
Member

@tech189 tech189 commented Apr 25, 2022

Description

  • Adds two new pieces of information to the scoop info command when using the -v verbose switch
  • If the app is installed, it will get the list of files inside the app's installation folder, its persist folder and any cached downloads.
  • Then it will add these up and display them one by one with a total underneath.
  • If the app isn't installed, then it will try to get the URL from the manifest for the current architecture and get the Content-Length header from the download server. It will add up the total for each file given in the manifest.
  • Then it will display the total download size or 'Unknown' if the server doesn't provide the info (e.g. sourceforge).
  • If the app is cached but not installed, it will let the user know if the latest version is in the cache.

For example, for installed apps:

Name           : sharex
Description    : Screen capture, file sharing and productivity tool.
<other properties...>
Installed size : App: 16.1 MB
                 Persist: 768.3 KB
                 Cache: 7.2 MB
                 Total: 24.1 MB
Binaries       : ShareX.exe
Shortcuts      : ShareX

Another example with a not yet installed app:

Name          : vlc
Description   : A free and open source cross-platform multimedia player and framework that plays most multimedia files
                as well as DVDs, Audio CDs, VCDs, and various streaming protocols.
<other properties...>
Download size : 35.2 MB
Binaries      : vlc.exe
Shortcuts     : VLC media player

An example with an app that is uninstalled but the latest version can be installed using cache:

Name          : chef-workstation
Description   : Chef Workstation is Chef's modern developer tool kit that includes Chef Infra, InSpec and Habitat plus
                a host of resources, helpers and testing tools that make automating infrastructure, application and
                security testing easier than ever. Chef Workstation supercedes ChefDK.
<other properties...>
Download size : 620.7 MB (latest version is cached)
Shortcuts     : Chef Workstation
Path Added    : C:\Users\me\scoop\apps\chef-workstation\current\bin

Motivation and Context

How Has This Been Tested?

  • Tested with many apps: those with and without persisted data or cached data, with those that are uninstalled and not.
  • Tested to see if it double counts persisted data when evaluating app size - it doesn't.
  • Tested the download size with manifests with architecture blocks and those without.
  • Tested download size with manifests with multiple urls and those with just one.

Checklist:

  • I have read the Contributing Guide.
  • I have updated the documentation accordingly.
    • added to changelog
  • I have updated the tests accordingly.
    • not sure which tests should be run

@rashil2000
Copy link
Member

Hey, this looks great, but I think you forgot to use the $verbose switch 😅

@tech189
Copy link
Member Author

tech189 commented Apr 27, 2022

Oops, yeah I totally forgot! I added the check now :)

@rashil2000
Copy link
Member

There's a catch here. When showing installed size, the code shows the sizes for previous app versions too. This is a bit wrong IMO, since the 'App size' will be double or triple (if there are 2/3 older versions kept) the actual size. One solution is to show another category 'Previous versions' and show their sizes separately from the 'current' version size.

libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
tech189 and others added 2 commits May 2, 2022 10:31
Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>
@tech189
Copy link
Member Author

tech189 commented May 3, 2022

Now it looks like this:

Installed size : Current version: 70.8 MB
                 Old versions: 139.5 MB
                 Persisted data: 8.1 MB
                 Cached downloads: 50.7 MB
                 Total: 269.1 MB

I had to make the category names a bit longer to make them line up roughly. Would it be a good idea to add further spaces so that they line up perfectly like so:

Installed size : Current version:  70.8 MB
                 Old versions:     139.5 MB
                 Persisted data:   8.1 MB
                 Cached downloads: 50.7 MB
                 Total:            269.1 MB

Or maybe a '-----' divider before the total? Or keep it as it is?

@rashil2000
Copy link
Member

Would it be a good idea to add further spaces so that they line up perfectly

Yes!

@tech189
Copy link
Member Author

tech189 commented May 4, 2022

Okay, sorted. Now each total lines up in a column :)

libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
@rashil2000
Copy link
Member

rashil2000 commented May 6, 2022

Idea: Should we omit a particular size field if its value is 0 B?

@tech189
Copy link
Member Author

tech189 commented May 6, 2022

Output is now as short as possible 🚀

For app with files in each category:

Installed size : Current version:  41.2 MB
                 Old versions:     35.4 MB
                 Persisted data:   882 B
                 Cached downloads: 20.1 MB
                 Total:            96.6 MB

App with no old versions:

Installed size : Current version:  311.4 MB
                 Persisted data:   21.1 MB
                 Cached downloads: 361.5 MB
                 Total:            693.9 MB

App with no persisted data:

Installed size : Current version:  13.9 MB
                 Cached downloads: 17.3 MB
                 Total:            31.2 MB

App with no cache either:

Installed size : 276.6 MB

rashil2000
rashil2000 previously approved these changes May 7, 2022
@rashil2000
Copy link
Member

rashil2000 commented Jun 16, 2022

@niheaven can this feature be released in 0.2.2? It's been sitting for a while.

@niheaven
Copy link
Member

Will review tomorrow and find something to tweak at a glance.

v0.2.2 fixes Get-Manifest()'s bugs and should be released ASAP.

Copy link
Member

@niheaven niheaven left a comment

Choose a reason for hiding this comment

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

Some tweak, and been tested

libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
libexec/scoop-info.ps1 Outdated Show resolved Hide resolved
tech189 and others added 3 commits June 21, 2022 14:32
Simplify `| Where-Object ...` to `-Filter`
Replace `totalSize` counter with `coalesce` function from `lib\core.ps1`
Move `currentFiles` counter into main `foreach` loop
Simplify categorised output by applying `filesize` afterwards
Simplify architecture check for download size with `url` function from `lib\manifest.ps1`

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
@tech189
Copy link
Member Author

tech189 commented Jun 21, 2022

Thanks for the review and tweaks! I think it's ready now, I've tested it all too.

I only found one issue but I think it's not related to my changes - I'll open up an issue after this is merged into develop. (if you install an app with app-name@x.x.x syntax, it does not show up in scoop-info as 'installed' - and so instead of showing app size, it will show the download size even though it is already installed)

niheaven
niheaven previously approved these changes Jun 21, 2022
niheaven
niheaven previously approved these changes Jun 21, 2022
@niheaven niheaven merged commit 4fec4d7 into ScoopInstaller:develop Jun 21, 2022
slaughtering pushed a commit to slaughtering/scoop that referenced this pull request Jul 7, 2022
Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
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.

None yet

3 participants