Skip to content

Commit

Permalink
Create asset pipeline cache directory on demand. (#3525)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Mar 18, 2024
1 parent d219398 commit 35f73df
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php
Expand Up @@ -227,7 +227,7 @@ protected function filterItems()

/**
* Get the path to the directory where we can cache files generated by
* this trait.
* this trait. The directory will be created if it does not already exist.
*
* @return string
*/
Expand All @@ -238,7 +238,14 @@ protected function getResourceCacheDir()
'Asset pipeline feature depends on the LOCAL_CACHE_DIR constant.'
);
}
return LOCAL_CACHE_DIR . '/public/';
// TODO: it might be better to use \VuFind\Cache\Manager here.
$cacheDir = LOCAL_CACHE_DIR . '/public/';
if (!is_dir($cacheDir) && !file_exists($cacheDir)) {
if (!mkdir($cacheDir)) {
throw new \Exception("Unexpected problem creating cache directory: $cacheDir");
}
}
return $cacheDir;
}

/**
Expand Down

0 comments on commit 35f73df

Please sign in to comment.