Skip to content

Commit 1dd479f

Browse files
authored
fix(database): Use 'Find-BucketDirectory()' to locate bucket dir (#5955)
1 parent 1752050 commit 1dd479f

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Features
44

5-
- **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), [#5948](https://github.com/ScoopInstaller/Scoop/issues/5948))
5+
- **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), [#5949](https://github.com/ScoopInstaller/Scoop/issues/5949), [#5955](https://github.com/ScoopInstaller/Scoop/issues/5955))
66
- **core:** New cache filename format ([#5929](https://github.com/ScoopInstaller/Scoop/issues/5929))
77

88
### Bug Fixes

lib/buckets.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function add_bucket($name, $repo) {
158158
Write-Host 'OK'
159159
if (get_config USE_SQLITE_CACHE) {
160160
info 'Updating cache...'
161-
Set-ScoopDB -Path (Get-ChildItem -Path $dir -Filter '*.json' -Recurse).FullName
161+
Set-ScoopDB -Path (Get-ChildItem (Find-BucketDirectory $name) -Filter '*.json' -Recurse).FullName
162162
}
163163
success "The $name bucket was added successfully."
164164
return 0

lib/database.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ function Set-ScoopDB {
199199
}
200200
process {
201201
if ($Path.Count -eq 0) {
202-
$bucketPath = Get-LocalBucket | ForEach-Object { Join-Path $bucketsdir $_ }
202+
$bucketPath = Get-LocalBucket | ForEach-Object { Find-BucketDirectory $_ }
203203
$Path = (Get-ChildItem $bucketPath -Filter '*.json' -Recurse).FullName
204204
}
205-
$Path | Where-Object { $_ -notmatch '[\\/]\.|[\\/]deprecated[\\/]' } | ForEach-Object {
205+
$Path | ForEach-Object {
206206
$manifestRaw = [System.IO.File]::ReadAllText($_)
207207
$manifest = ConvertFrom-Json $manifestRaw -ErrorAction SilentlyContinue
208208
if ($null -ne $manifest.version) {

libexec/scoop-update.ps1

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,38 +186,43 @@ function Sync-Bucket {
186186
# Parallel parameter is available since PowerShell 7
187187
$buckets | Where-Object { $_.valid } | ForEach-Object -ThrottleLimit 5 -Parallel {
188188
. "$using:PSScriptRoot\..\lib\core.ps1"
189+
. "$using:PSScriptRoot\..\lib\buckets.ps1"
189190

190-
$bucketLoc = $_.path
191191
$name = $_.name
192+
$bucketLoc = $_.path
193+
$innerBucketLoc = Find-BucketDirectory $name
192194

193195
$previousCommit = Invoke-Git -Path $bucketLoc -ArgumentList @('rev-parse', 'HEAD')
194196
Invoke-Git -Path $bucketLoc -ArgumentList @('pull', '-q')
195197
if ($using:Log) {
196198
Invoke-GitLog -Path $bucketLoc -Name $name -CommitHash $previousCommit
197199
}
198200
if (get_config USE_SQLITE_CACHE) {
199-
Invoke-Git -Path $bucketLoc -ArgumentList @('diff', '--name-only', '--diff-filter=d', $previousCommit) | Where-Object {
200-
$_ -match '^[^.].*\.json$'
201-
} | ForEach-Object {
202-
[void]($using:updatedFiles).Add($(Join-Path $bucketLoc $_))
201+
Invoke-Git -Path $bucketLoc -ArgumentList @('diff', '--name-only', '--diff-filter=d', $previousCommit) | ForEach-Object {
202+
$filePath = Join-Path $bucketLoc $_
203+
if ($filePath -match "^$([regex]::Escape($innerBucketLoc)).*\.json$") {
204+
[void]($using:updatedFiles).Add($filePath)
205+
}
203206
}
204207
}
205208
}
206209
} else {
207210
$buckets | Where-Object { $_.valid } | ForEach-Object {
208-
$bucketLoc = $_.path
209211
$name = $_.name
212+
$bucketLoc = $_.path
213+
$innerBucketLoc = Find-BucketDirectory $name
210214

211215
$previousCommit = Invoke-Git -Path $bucketLoc -ArgumentList @('rev-parse', 'HEAD')
212216
Invoke-Git -Path $bucketLoc -ArgumentList @('pull', '-q')
213217
if ($Log) {
214218
Invoke-GitLog -Path $bucketLoc -Name $name -CommitHash $previousCommit
215219
}
216220
if (get_config USE_SQLITE_CACHE) {
217-
Invoke-Git -Path $bucketLoc -ArgumentList @('diff', '--name-only', '--diff-filter=d', $previousCommit) | Where-Object {
218-
$_ -match '^[^.].*\.json$'
219-
} | ForEach-Object {
220-
[void]($updatedFiles).Add($(Join-Path $bucketLoc $_))
221+
Invoke-Git -Path $bucketLoc -ArgumentList @('diff', '--name-only', '--diff-filter=d', $previousCommit) | ForEach-Object {
222+
$filePath = Join-Path $bucketLoc $_
223+
if ($filePath -match "^$([regex]::Escape($innerBucketLoc)).*\.json$") {
224+
[void]($updatedFiles).Add($filePath)
225+
}
221226
}
222227
}
223228
}

0 commit comments

Comments
 (0)