Skip to content

fix(bucket): Return empty list correctly in Get-LocalBucket#4885

Merged
niheaven merged 1 commit intoScoopInstaller:developfrom
lewis-yeung:develop
Apr 27, 2022
Merged

fix(bucket): Return empty list correctly in Get-LocalBucket#4885
niheaven merged 1 commit intoScoopInstaller:developfrom
lewis-yeung:develop

Conversation

@lewis-yeung
Copy link
Copy Markdown
Contributor

Description

  1. Return a zero-length list instead of $null in Get-LocalBucket.

  2. Adjust the output message for scoop alias list when there is no alias found.

  3. Adjust the output message for scoop cache show when there is no cache found.

Motivation and Context

  1. I ran into an error when I removed all buckets and was trying to add them back using URLs of mirrors, which means running scoop bucket list when there is nothing in $SCOOP\buckets:

    Get-Item: <path_to_scoop>\apps\scoop\current\lib\buckets.ps1:134:32
    Line |
     134 |              $bucket.Updated = (Get-Item "$path\bucket").LastWriteTime
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~
         | Cannot find path '<path_to_scoop>\buckets\main\bucket' because it does not exist.
    

    The Get-LocalBucket returns $null in this case, so Find-BucketDirectory gets the default value main for $Name:

    Scoop/lib/buckets.ps1

    Lines 126 to 128 in e6d0371

    Get-LocalBucket | ForEach-Object {
    $bucket = [Ordered]@{ Name = $_ }
    $path = Find-BucketDirectory $_ -Root

    Scoop/lib/buckets.ps1

    Lines 13 to 14 in e6d0371

    param(
    [string] $Name = 'main',

    To fix this, we should use a zero-length list instead and give a tip of adding the default main bucket.

  2. No additional description.

  3. scoop cache show shows the following message when there is no cache found:

    Total: 0 files,  B
    

    I think it's better to change it to something like this:

    No cache found.
    

How Has This Been Tested?

Just run as usual:

scoop bucket list
scoop alias list
scoop cache show

Checklist:

Comment thread libexec/scoop-cache.ps1 Outdated
Comment thread libexec/scoop-alias.ps1 Outdated
Comment thread lib/buckets.ps1 Outdated
@lewis-yeung
Copy link
Copy Markdown
Contributor Author

@rashil2000 Changed and re-pushed. Please take a look. Thanks for your patience.

rashil2000
rashil2000 previously approved these changes Apr 25, 2022
Comment thread lib/buckets.ps1 Outdated
Comment thread libexec/scoop-cache.ps1 Outdated
Comment thread lib/buckets.ps1 Outdated
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
Co-authored-by: Rashil Gandhi <rashil2000@gmail.com>
@niheaven niheaven merged commit 22365c2 into ScoopInstaller:develop Apr 27, 2022
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.

3 participants