@@ -211,6 +211,20 @@ class DownloadCacheEntry {
211
211
hidden [string ]$Path
212
212
}
213
213
214
+ filter ListEntries ($FilterSb ) {
215
+ foreach ($Source in $_.SourcePackages | ? $FilterSb ) {
216
+ [DownloadCacheEntry ]@ {
217
+ PackageName = $Source.PackageName
218
+ Version = $Source.ManifestVersion
219
+ Hash = $_.EntryKey
220
+ FileName = [System.IO.Path ]::GetFileName($_.Path )
221
+
222
+ Size = $_.Size
223
+ Path = [System.IO.Path ]::GetDirectoryName($_.Path )
224
+ }
225
+ }
226
+ }
227
+
214
228
function Get-PogDownloadCache {
215
229
[CmdletBinding (PositionalBinding = $false )]
216
230
[OutputType ([DownloadCacheEntry ])]
@@ -224,33 +238,17 @@ function Get-PogDownloadCache {
224
238
begin {
225
239
$Entries = [array ][Pog.InternalState ]::DownloadCache.EnumerateEntries()
226
240
227
- function ListEntries ($FilterSb ) {
228
- foreach ($Entry in $Entries ) {
229
- foreach ($Source in $Entry.SourcePackages | ? $FilterSb ) {
230
- [DownloadCacheEntry ]@ {
231
- PackageName = $Source.PackageName
232
- Version = $Source.ManifestVersion
233
- Hash = $Entry.EntryKey
234
- FileName = [System.IO.Path ]::GetFileName($Entry.Path )
235
-
236
- Size = $Entry.Size
237
- Path = [System.IO.Path ]::GetDirectoryName($Entry.Path )
238
- }
239
- }
240
- }
241
- }
242
-
243
241
if (-not $MyInvocation.ExpectingInput -and -not $PackageName ) {
244
- ListEntries {$true }
242
+ $Entries | ListEntries {$true }
245
243
}
246
244
}
247
245
248
246
process {
249
247
foreach ($pn in $PackageName ) {
250
- $Result = ListEntries {$_.PackageName -eq $pn }
251
- echo $Result
252
-
253
- if ( -not $Result ) {
248
+ $Result = $Entries | ListEntries {$_.PackageName -eq $pn }
249
+ if ( $Result ) {
250
+ echo $Result
251
+ } else {
254
252
# hacky way to create an ErrorRecord
255
253
$e = try {throw " No download cache entries found for package '$pn '." } catch {$_ }
256
254
$PSCmdlet.WriteError ($e )
0 commit comments