|
11 | 11 | /** |
12 | 12 | * Extends the default FileFetcher and uses hirak/prestissimo for parallel |
13 | 13 | * downloads. |
| 14 | + * |
| 15 | + * @deprecated Use the GuzzleFileFetcher instead. |
14 | 16 | */ |
15 | 17 | class PrestissimoFileFetcher extends FileFetcher { |
16 | 18 |
|
17 | | - /** |
18 | | - * @var \Composer\Config |
19 | | - */ |
20 | | - protected $config; |
21 | | - |
22 | | - /** |
23 | | - * Constructs this PrestissimoFileFetcher object. |
24 | | - */ |
25 | | - public function __construct(RemoteFilesystem $remoteFilesystem, $source, IOInterface $io, $progress = TRUE, Config $config) { |
26 | | - parent::__construct($remoteFilesystem, $source, $io, $progress); |
27 | | - $this->config = $config; |
28 | | - } |
29 | | - |
30 | | - /** |
31 | | - * {@inheritdoc} |
32 | | - */ |
33 | | - public function fetch($version, $destination, $override) { |
34 | | - if (class_exists(CurlMulti::class)) { |
35 | | - $this->fetchWithPrestissimo($version, $destination, $override); |
36 | | - return; |
37 | | - } |
38 | | - parent::fetch($version, $destination, $override); |
39 | | - } |
40 | | - |
41 | | - /** |
42 | | - * Fetch files in parallel. |
43 | | - */ |
44 | | - protected function fetchWithPrestissimo($version, $destination, $override) { |
45 | | - $requests = []; |
46 | | - |
47 | | - foreach ($this->filenames as $sourceFilename => $filename) { |
48 | | - $target = "$destination/$filename"; |
49 | | - if ($override || !file_exists($target)) { |
50 | | - $url = $this->getUri($sourceFilename, $version); |
51 | | - $this->fs->ensureDirectoryExists($destination . '/' . dirname($filename)); |
52 | | - $requests[] = new CopyRequest($url, $target, FALSE, $this->io, $this->config); |
53 | | - } |
54 | | - } |
55 | | - |
56 | | - $successCnt = $failureCnt = 0; |
57 | | - $totalCnt = count($requests); |
58 | | - if ($totalCnt == 0) { |
59 | | - return; |
60 | | - } |
61 | | - |
62 | | - $multi = new CurlMulti(); |
63 | | - $multi->setRequests($requests); |
64 | | - do { |
65 | | - $multi->setupEventLoop(); |
66 | | - $multi->wait(); |
67 | | - $result = $multi->getFinishedResults(); |
68 | | - $successCnt += $result['successCnt']; |
69 | | - $failureCnt += $result['failureCnt']; |
70 | | - if ($this->progress) { |
71 | | - foreach ($result['urls'] as $url) { |
72 | | - $this->io->writeError(" - Downloading <comment>$successCnt</comment>/<comment>$totalCnt</comment>: <info>$url</info>", TRUE); |
73 | | - } |
74 | | - } |
75 | | - } while ($multi->remain()); |
76 | | - } |
77 | | - |
78 | 19 | } |
0 commit comments