Add temporary metadata for download size tracking
parent
96370657b8
commit
3f243d37c3
|
@ -57,6 +57,13 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
protected $eventDispatcher;
|
protected $eventDispatcher;
|
||||||
/** @var ProcessExecutor */
|
/** @var ProcessExecutor */
|
||||||
protected $process;
|
protected $process;
|
||||||
|
/**
|
||||||
|
* @var array<string, int|string>
|
||||||
|
* @private
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public static $downloadMetadata = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private this is only public for php 5.3 support in closures
|
* @private this is only public for php 5.3 support in closures
|
||||||
*
|
*
|
||||||
|
@ -218,6 +225,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
$accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
|
$accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
|
||||||
$url = reset($urls);
|
$url = reset($urls);
|
||||||
$cacheKey = $url['cacheKey'];
|
$cacheKey = $url['cacheKey'];
|
||||||
|
FileDownloader::$downloadMetadata[$package->getName()] = @filesize($fileName) ?: $response->getHeader('Content-Length') ?: '?';
|
||||||
|
|
||||||
if ($cache && !$cache->isReadOnly()) {
|
if ($cache && !$cache->isReadOnly()) {
|
||||||
$self->lastCacheWrites[$package->getName()] = $cacheKey;
|
$self->lastCacheWrites[$package->getName()] = $cacheKey;
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
||||||
|
use Composer\Downloader\FileDownloader;
|
||||||
use Composer\EventDispatcher\EventDispatcher;
|
use Composer\EventDispatcher\EventDispatcher;
|
||||||
use Composer\Util\Loop;
|
use Composer\Util\Loop;
|
||||||
use Composer\Util\Platform;
|
use Composer\Util\Platform;
|
||||||
|
@ -65,6 +66,7 @@ class InstallationManager
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->notifiablePackages = array();
|
$this->notifiablePackages = array();
|
||||||
|
FileDownloader::$downloadMetadata = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -662,10 +664,18 @@ class InstallationManager
|
||||||
|
|
||||||
$postData = array('downloads' => array());
|
$postData = array('downloads' => array());
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
$postData['downloads'][] = array(
|
$packageNotification = array(
|
||||||
'name' => $package->getPrettyName(),
|
'name' => $package->getPrettyName(),
|
||||||
'version' => $package->getVersion(),
|
'version' => $package->getVersion(),
|
||||||
);
|
);
|
||||||
|
if (strpos($repoUrl, 'packagist.org/') !== false) {
|
||||||
|
if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
|
||||||
|
$packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
|
||||||
|
} else {
|
||||||
|
$packageNotification['downloaded'] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$postData['downloads'][] = $packageNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
$opts = array(
|
$opts = array(
|
||||||
|
|
Loading…
Reference in New Issue