Skip to content

Commit

Permalink
fix: Create cache directory if does not exist (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Nov 22, 2021
1 parent 8175fdb commit f17dd14
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Show-CachedFileList {
$regex = $ApplicationFilter -join '|'
if (!$ApplicationFilter) { $regex = '.*?' }

$files = Get-ChildItem -LiteralPath $SCOOP_CACHE_DIRECTORY -File | Where-Object -Property 'Name' -Match -Value "^($regex)#"
$files = Get-ChildItem -LiteralPath $SCOOP_CACHE_DIRECTORY -ErrorAction 'SilentlyContinue' -File | Where-Object -Property 'Name' -Match -Value "^($regex)#"
$totalSize = [double] ($files | Measure-Object -Property 'Length' -Sum).Sum

$_app = @{ 'Expression' = { "$($_.app) ($($_.version))" } }
Expand Down
6 changes: 6 additions & 0 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ function dl_urls($app, $version, $manifest, $bucket, $architecture, $dir, $use_c
$extract_tos = @(extract_to $manifest $architecture)
$extracted = 0

try {
Confirm-DirectoryExistence -LiteralPath $SCOOP_CACHE_DIRECTORY | Out-Null
} catch {
throw [ScoopException] "Could not create cache directory: '$SCOOP_CACHE_DIRECTORY'"
}

# Download first
if (Test-Aria2Enabled) {
dl_with_cache_aria2 $app $version $manifest $architecture $dir $cookies $use_cache $check_hash
Expand Down
6 changes: 6 additions & 0 deletions libexec/scoop-download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ if ($opt.b -or $opt.'all-architectures') { $Architecture = $SHOVEL_SUPPORTED_ARC
$exitCode = 0
$problems = 0

try {
Confirm-DirectoryExistence -LiteralPath $SCOOP_CACHE_DIRECTORY | Out-Null
} catch {
Stop-ScoopExecution -Message "Could not create cache directory: '$SCOOP_CACHE_DIRECTORY' ($($_.Exception.Message))"
}

foreach ($app in $application) {
$resolved = $null
try {
Expand Down

0 comments on commit f17dd14

Please sign in to comment.