1414
1515class PrestissimoFileFetcher extends FileFetcher {
1616
17- /**
18- * @var \Composer\IO\IOInterface
19- */
20- protected $ io ;
21-
2217 /**
2318 * @var \Composer\Config
2419 */
2520 protected $ config ;
2621
27- public function __construct (\Composer \Util \RemoteFilesystem $ remoteFilesystem , $ source , array $ filenames = [], IOInterface $ io , Config $ config ) {
28- parent ::__construct ($ remoteFilesystem , $ source , $ filenames );
29- $ this ->io = $ io ;
22+ public function __construct (\Composer \Util \RemoteFilesystem $ remoteFilesystem , $ source , IOInterface $ io , $ progress = TRUE , Config $ config ) {
23+ parent ::__construct ($ remoteFilesystem , $ source , $ io , $ progress );
3024 $ this ->config = $ config ;
3125 }
3226
33- public function fetch ($ version , $ destination ) {
27+ public function fetch ($ version , $ destination, $ override ) {
3428 if (class_exists (CurlMulti::class)) {
35- $ this ->fetchWithPrestissimo ($ version , $ destination );
29+ $ this ->fetchWithPrestissimo ($ version , $ destination, $ override );
3630 return ;
3731 }
38- parent ::fetch ($ version , $ destination );
32+ parent ::fetch ($ version , $ destination, $ override );
3933 }
4034
41- protected function fetchWithPrestissimo ($ version , $ destination ) {
35+ protected function fetchWithPrestissimo ($ version , $ destination, $ override ) {
4236 $ requests = [];
43- array_walk ($ this ->filenames , function ($ filename ) use ($ version , $ destination , &$ requests ) {
44- $ url = $ this ->getUri ($ filename , $ version );
45- $ this ->fs ->ensureDirectoryExists ($ destination . '/ ' . dirname ($ filename ));
46- $ requests [] = new CopyRequest ($ url , $ destination . '/ ' . $ filename , false , $ this ->io , $ this ->config );
47- });
37+
38+ foreach ($ this ->filenames as $ sourceFilename => $ filename ) {
39+ $ target = "$ destination/ $ filename " ;
40+ if ($ override || !file_exists ($ target )) {
41+ $ url = $ this ->getUri ($ sourceFilename , $ version );
42+ $ this ->fs ->ensureDirectoryExists ($ destination . '/ ' . dirname ($ filename ));
43+ $ requests [] = new CopyRequest ($ url , $ target , false , $ this ->io , $ this ->config );
44+ }
45+ }
4846
4947 $ successCnt = $ failureCnt = 0 ;
5048 $ totalCnt = count ($ requests );
@@ -57,8 +55,10 @@ protected function fetchWithPrestissimo($version, $destination) {
5755 $ result = $ multi ->getFinishedResults ();
5856 $ successCnt += $ result ['successCnt ' ];
5957 $ failureCnt += $ result ['failureCnt ' ];
60- foreach ($ result ['urls ' ] as $ url ) {
61- $ this ->io ->writeError (" <comment> $ successCnt/ $ totalCnt</comment>: \t$ url " , true , \Composer \IO \IOInterface::VERBOSE );
58+ if ($ this ->progress ) {
59+ foreach ($ result ['urls ' ] as $ url ) {
60+ $ this ->io ->writeError (" - Downloading <comment> $ successCnt</comment>/<comment> $ totalCnt</comment>: <info> $ url</info> " , true );
61+ }
6262 }
6363 } while ($ multi ->remain ());
6464 }
0 commit comments