@@ -66,18 +66,23 @@ public function downloadPackages(callable $progressCallback = null): array
66
66
67
67
$ contents = $ this ->packageResolver ->downloadPackages ($ remoteEntriesToDownload , $ progressCallback );
68
68
$ downloadedPackages = [];
69
- foreach ($ contents as $ package => $ content ) {
70
- if (!isset ($ remoteEntriesToDownload [$ package ])) {
71
- throw new \LogicException (sprintf ('The package "%s" was not in the requested packages . ' , $ package ));
69
+ foreach ($ remoteEntriesToDownload as $ package => $ entry ) {
70
+ if (!isset ($ contents [$ package ])) {
71
+ throw new \LogicException (sprintf ('The package "%s" was not downloaded . ' , $ package ));
72
72
}
73
73
74
- $ filename = $ this ->savePackage ($ package , $ content , $ remoteEntriesToDownload [$ package ]->type );
74
+ $ filename = $ this ->savePackage ($ package , $ contents [$ package ], $ entry ->type );
75
75
$ newInstalled [$ package ] = [
76
76
'path ' => $ filename ,
77
- 'version ' => $ remoteEntriesToDownload [ $ package ] ->version ,
77
+ 'version ' => $ entry ->version ,
78
78
];
79
79
80
80
$ downloadedPackages [] = $ package ;
81
+ unset($ contents [$ package ]);
82
+ }
83
+
84
+ if ($ contents ) {
85
+ throw new \LogicException (sprintf ('The following packages were unexpectedly downloaded: "%s". ' , implode ('", " ' , array_keys ($ contents ))));
81
86
}
82
87
83
88
$ this ->saveInstalled ($ newInstalled );
@@ -124,10 +129,6 @@ private function loadInstalled(): array
124
129
}
125
130
126
131
$ installedPath = $ this ->vendorDir .'/installed.php ' ;
127
- if (!is_file ($ installedPath )) {
128
- return [];
129
- }
130
-
131
132
$ installed = is_file ($ installedPath ) ? (static fn () => include $ installedPath )() : [];
132
133
133
134
foreach ($ installed as $ package => $ data ) {
0 commit comments