Skip to content

Commit

Permalink
Fix corrupt archives in cache from getting the installs stuck forever…
Browse files Browse the repository at this point in the history
…, and make sure it fails only once, fixes #10028
  • Loading branch information
Seldaek committed Aug 17, 2021
1 parent e49f24e commit ddd7920
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Composer/Downloader/FileDownloader.php
Expand Up @@ -168,6 +168,12 @@ public function download(PackageInterface $package, $path, PackageInterface $pre
if ($output) {
$io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
}
// mark the file as having been written in cache even though it is only read from cache, so that if
// the cache is corrupt the archive will be deleted and the next attempt will re-download it
// see https://github.com/composer/composer/issues/10028
if (!$cache->isReadOnly()) {
$this->lastCacheWrites[$package->getName()] = $cacheKey;
}
$result = \React\Promise\resolve($fileName);
} else {
if ($output) {
Expand Down

0 comments on commit ddd7920

Please sign in to comment.