Skip to content

Commit

Permalink
Fix composer install with --no-cache flag (#520)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Dave Reid <dave@davereid.net>
  • Loading branch information
justafish and davereid committed Apr 15, 2024
1 parent de90cf8 commit 4320a29
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/TestBinaryInstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@ jobs:
run: |
ddev exec touch /var/www/html/composer-cache/files/lullabot/drainpipe/bin/task/3.28.0/task_linux_amd64.tar
ddev composer install
- name: Test installing without composer cache
run: |
ddev composer install --no-cache
test -x vendor/bin/task
ddev composer install
test -x vendor/bin/task
rm -rf vendor
ddev composer install
test -x vendor/bin/task
rm -rf vendor
ddev composer install --no-cache
test -x vendor/bin/task
13 changes: 9 additions & 4 deletions src/BinaryInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,15 @@ protected function installBinary($binary, $version, $url, $sha, $hashalgo = 'sha
$httpDownloader = Factory::createHttpDownloader($this->io, $this->config);
$parts = explode('/', $url);
$fileName = array_pop($parts);
$cacheFolder = $this->cache->getRoot().$binary.\DIRECTORY_SEPARATOR.$version;
$cacheDestination = $cacheFolder.\DIRECTORY_SEPARATOR.$fileName;
$cacheExtractedBinary = $cacheFolder.\DIRECTORY_SEPARATOR.$binary;
$binDestination = $bin.\DIRECTORY_SEPARATOR.$binary;
if ($this->cache->isEnabled()) {
$cacheFolder = $this->cache->getRoot() . $binary . \DIRECTORY_SEPARATOR . $version;
}
else {
$cacheFolder = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . $binary . \DIRECTORY_SEPARATOR . $version;
}
$cacheDestination = $cacheFolder . \DIRECTORY_SEPARATOR . $fileName;
$cacheExtractedBinary = $cacheFolder . \DIRECTORY_SEPARATOR . $binary;
$binDestination = $bin . \DIRECTORY_SEPARATOR . $binary;

// Check the cache.
$fs->ensureDirectoryExists($cacheFolder);
Expand Down

0 comments on commit 4320a29

Please sign in to comment.