Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix composer install with --no-cache flag #520

Merged
merged 7 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/TestBinaryInstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ 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
ddev composer install
rm -rf vendor
ddev composer install
rm -rf vendor
ddev composer install --no-cache
justafish marked this conversation as resolved.
Show resolved Hide resolved
justafish marked this conversation as resolved.
Show resolved Hide resolved
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