matthiasblaesing commented on a change in pull request #31:
URL: https://github.com/apache/netbeans-tools/pull/31#discussion_r436582960
##########
File path: pp3/module/Application/src/Application/Pp/Catalog.php
##########
@@ -120,7 +205,89 @@ public function storeXml($destinationFolder, $xml) {
$gz =gzopen($path.'.gz', 'w9');
gzwrite($gz, $xml);
gzclose($gz);
- return true;
+ return true;
}
+ /**
+ * Update the info XML for the module
+ *
+ * @param \Application\Entity\PluginVersion $pluginVersion
+ */
+ private function updateInfoXML($pluginVersion) {
+ $sha1Reference = false;
+ $sha256Reference = false;
+
+ foreach ($pluginVersion->getDigests() as $digest) {
+ if ($digest->getAlgorithm() == 'SHA-1') {
+ $sha1Reference = $digest->getValue();
+ } else if ($digest->getAlgorithm() == 'SHA-256') {
+ $sha256Reference = $digest->getValue();
+ }
+ }
+
+ // Skip update if:
+ // - info.xml is present (PP3 assumes immutable sources)
+ // - SHA-256 checksum is present
+ // - artifact size is present
+ if($pluginVersion->getInfoXml() != null &&
$pluginVersion->getArtifactSize() && $sha256Reference) {
+ return;
+ }
+ // Fetch NBM
+ $client = new Client($pluginVersion->getUrl(), array(
+ 'maxredirects' => 0,
+ 'timeout' => 30
+ ));
+ $response = $client->send();
+ if ($response->isSuccess()) {
+ // Store result to file to make it processible by ZipArchive
+ $archiveFile = tempnam(sys_get_temp_dir(), "mvn-download");
+ $fid = fopen($archiveFile, "w");
+ fwrite($fid, $response->getBody());
+ fclose($fid);
+ $response = null;
+
+ $filesize = filesize($archiveFile);
+ $sha1 = hash_file("sha1", $archiveFile);
+ $sha256 = hash_file("sha256", $archiveFile);
+
+ if(strtolower($sha1) != $sha1Reference) {
+ error_log(sprintf('PluginVersion(id: %d) SHA-1 message digest
does not match artifact. Expected: %s, Got: %s', $pluginVersion->getId(),
$sha1Reference, $sha1));
+ return;
+ }
+
+ if(! $sha256Reference) {
+ $pluginVersion->addDigest('SHA-256', $sha256);
+ }
+
+ if(substr(strtolower($pluginVersion->getUrl()), -4) == '.jar') {
+ $execution = self::OSGI_JAR_PARSER . " " .
escapeshellarg($archiveFile);
+ $return_var = -1;
+ $output = [];
+ exec($execution, $output, $return_var);
+ $outputString = implode("\n", $output);
+ if(intval($return_var) != 0) {
+ error_log(sprintf('PluginVersion(id: %d) Failed to extract
info from JAR, Got: %s', $pluginVersion->getId(), $outputString));
+ return;
+ }
+ $infoXML = $outputString;
+ } else {
+ // Extract Info/info.xml from archive
+ $archive = new ZipArchive();
Review comment:
On which server and is this recent? It was observed in production prior
to the installation of php7.0-zip, after that the required class is present and
can be loaded. As the regeneration after the update worked, the archives must
have been readable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists