fix(database): Update cache when adding bucket (#5946)

This commit is contained in:
Hsiao-nan Cheung
2024-05-08 18:10:13 +08:00
committed by GitHub
parent cc863353e2
commit 776135e0ab
4 changed files with 13 additions and 4 deletions

View File

@@ -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

View File

@@ -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
}

View File

@@ -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')

View File

@@ -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>'