@@ -22,8 +22,8 @@ class PrestissimoFileFetcher extends FileFetcher {
22
22
/**
23
23
* Constructs this PrestissimoFileFetcher object.
24
24
*/
25
- public function __construct (RemoteFilesystem $ remoteFilesystem , $ source , IOInterface $ io , $ progress = TRUE , Config $ config ) {
26
- parent ::__construct ($ remoteFilesystem , $ source , $ io , $ progress );
25
+ public function __construct (RemoteFilesystem $ remoteFilesystem , IOInterface $ io , $ progress = TRUE , Config $ config ) {
26
+ parent ::__construct ($ remoteFilesystem , $ io , $ progress );
27
27
$ this ->config = $ config ;
28
28
}
29
29
@@ -32,10 +32,9 @@ public function __construct(RemoteFilesystem $remoteFilesystem, $source, IOInter
32
32
*/
33
33
public function fetch ($ version , $ destination , $ override ) {
34
34
if (class_exists (CurlMulti::class)) {
35
- $ this ->fetchWithPrestissimo ($ version , $ destination , $ override );
36
- return ;
35
+ return $ this ->fetchWithPrestissimo ($ version , $ destination , $ override );
37
36
}
38
- parent ::fetch ($ version , $ destination , $ override );
37
+ return parent ::fetch ($ version , $ destination , $ override );
39
38
}
40
39
41
40
/**
@@ -57,7 +56,7 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
57
56
$ errors = [];
58
57
$ totalCnt = count ($ requests );
59
58
if ($ totalCnt == 0 ) {
60
- return ;
59
+ return TRUE ;
61
60
}
62
61
63
62
$ multi = new CurlMulti ();
@@ -70,6 +69,9 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
70
69
$ failureCnt += $ result ['failureCnt ' ];
71
70
if (isset ($ result ['errors ' ])) {
72
71
$ errors += $ result ['errors ' ];
72
+ foreach ($ result ['errors ' ] as $ url => $ error ) {
73
+ $ this ->io ->writeError (" - Downloading <comment> $ successCnt</comment>/<comment> $ totalCnt</comment>: <info> $ url</info> (<error>failed</error>) " , TRUE );
74
+ }
73
75
}
74
76
if ($ this ->progress ) {
75
77
foreach ($ result ['urls ' ] as $ url ) {
@@ -78,10 +80,20 @@ protected function fetchWithPrestissimo($version, $destination, $override) {
78
80
}
79
81
} while ($ multi ->remain ());
80
82
81
- $ urls = array_keys ($ errors );
82
- if ($ urls ) {
83
- throw new \Exception ('Failed to download ' . implode (", " , $ urls ));
83
+ if ($ errors ) {
84
+ $ this ->addError ('Failed to download: ' . "\r\n" . implode ("\r\n" , array_keys ($ errors )));
85
+ $ errors_extra = [];
86
+ foreach ($ errors as $ error ) {
87
+ if ($ error !== "0: " && !isset ($ errors_extra [$ error ])) {
88
+ $ errors_extra [$ error ] = $ error ;
89
+ }
90
+ }
91
+ if ($ errors_extra ) {
92
+ $ this ->addError (implode ("\r\n" , $ errors_extra ));
93
+ }
94
+ return FALSE ;
84
95
}
96
+ return TRUE ;
85
97
}
86
98
87
99
}
0 commit comments