|
@@ -137,8 +137,11 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
$checksum = $package->getDistSha1Checksum();
|
|
|
$cacheKey = $this->getCacheKey($package, $processedUrl);
|
|
|
|
|
|
- // download if we don't have it in cache or the cache is invalidated
|
|
|
- if (!$this->cache || ($checksum && $checksum !== $this->cache->sha1($cacheKey)) || !$this->cache->copyTo($cacheKey, $fileName)) {
|
|
|
+ // use from cache if it is present and has a valid checksum or we have no checksum to check against
|
|
|
+ if ($this->cache && (!$checksum || $checksum === $this->cache->sha1($cacheKey)) && $this->cache->copyTo($cacheKey, $fileName)) {
|
|
|
+ $this->io->writeError('Loading from cache', false);
|
|
|
+ } else {
|
|
|
+ // download if cache restore failed
|
|
|
if (!$this->outputProgress) {
|
|
|
$this->io->writeError('Downloading', false);
|
|
|
}
|
|
@@ -168,10 +171,6 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
$this->lastCacheWrites[$package->getName()] = $cacheKey;
|
|
|
$this->cache->copyFrom($cacheKey, $fileName);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (!$this->outputProgress) {
|
|
|
- $this->io->writeError('Loading from cache', false);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if (!file_exists($fileName)) {
|
|
@@ -297,19 +296,27 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
$this->io = new NullIO;
|
|
|
$this->io->loadConfiguration($this->config);
|
|
|
$this->outputProgress = false;
|
|
|
+ $e = null;
|
|
|
|
|
|
- $this->download($package, $targetDir.'_compare', false);
|
|
|
-
|
|
|
- $comparer = new Comparer();
|
|
|
- $comparer->setSource($targetDir.'_compare');
|
|
|
- $comparer->setUpdate($targetDir);
|
|
|
- $comparer->doCompare();
|
|
|
- $output = $comparer->getChanged(true, true);
|
|
|
- $this->filesystem->removeDirectory($targetDir.'_compare');
|
|
|
+ try {
|
|
|
+ $this->download($package, $targetDir.'_compare', false);
|
|
|
+
|
|
|
+ $comparer = new Comparer();
|
|
|
+ $comparer->setSource($targetDir.'_compare');
|
|
|
+ $comparer->setUpdate($targetDir);
|
|
|
+ $comparer->doCompare();
|
|
|
+ $output = $comparer->getChanged(true, true);
|
|
|
+ $this->filesystem->removeDirectory($targetDir.'_compare');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
|
|
|
$this->io = $prevIO;
|
|
|
$this->outputProgress = $prevProgress;
|
|
|
|
|
|
+ if ($e) {
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
+
|
|
|
return trim($output);
|
|
|
}
|
|
|
}
|