Skip to content

Commit

Permalink
fix(database): Update cache when adding bucket (#5946)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven authored May 8, 2024
1 parent cc86335 commit 776135e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Features

- **scoop-search:** Use SQLite for caching apps to speed up local search ([#5851](https://github.com/ScoopInstaller/Scoop/issues/5851), [#5918](https://github.com/ScoopInstaller/Scoop/issues/5918))
- **core:** New cache filename format ([#5929](https://github.com/ScoopInstaller/Scoop/issues/5929)
- **scoop-search:** Use SQLite for caching apps to speed up local search ([#5851](https://github.com/ScoopInstaller/Scoop/issues/5851), [#5918](https://github.com/ScoopInstaller/Scoop/issues/5918), [#5946](https://github.com/ScoopInstaller/Scoop/issues/5946))
- **core:** New cache filename format ([#5929](https://github.com/ScoopInstaller/Scoop/issues/5929))

### Bug Fixes

Expand Down
4 changes: 4 additions & 0 deletions lib/buckets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ function add_bucket($name, $repo) {
$dir = ensure $dir
Invoke-Git -ArgumentList @('clone', $repo, $dir, '-q')
Write-Host 'OK'
if (get_config USE_SQLITE_CACHE) {
info 'Updating cache...'
Set-ScoopDB -Path (Get-ChildItem -Path $dir -Filter '*.json' -Recurse).FullName
}
success "The $name bucket was added successfully."
return 0
}
Expand Down
4 changes: 2 additions & 2 deletions lib/database.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ function Set-ScoopDB {
$bucketPath = Get-LocalBucket | ForEach-Object { Join-Path $bucketsdir $_ }
$Path = (Get-ChildItem $bucketPath -Filter '*.json' -Recurse).FullName
}
$Path | ForEach-Object {
$Path | Where-Object { $_ -notmatch '[\\/]\.' } | ForEach-Object {
$manifestRaw = [System.IO.File]::ReadAllText($_)
$manifest = $manifestRaw | ConvertFrom-Json -ErrorAction Continue
$manifest = ConvertFrom-Json $manifestRaw -ErrorAction SilentlyContinue
if ($null -ne $manifest.version) {
$list.Add([pscustomobject]@{
name = $($_ -replace '.*[\\/]([^\\/]+)\.json$', '$1')
Expand Down
5 changes: 5 additions & 0 deletions libexec/scoop-bucket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
# scoop bucket known
param($cmd, $name, $repo)

if (get_config USE_SQLITE_CACHE) {
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\database.ps1"
}

$usage_add = 'usage: scoop bucket add <name> [<repo>]'
$usage_rm = 'usage: scoop bucket rm <name>'

Expand Down

0 comments on commit 776135e

Please sign in to comment.