Buildbot: Move checksum to JSON #7
@ -22,7 +22,7 @@ class Build {
|
|||||||
public $file_size;
|
public $file_size;
|
||||||
public $file_extension;
|
public $file_extension;
|
||||||
public $release_cycle;
|
public $release_cycle;
|
||||||
public $sha256_checksum; // New property
|
public $sha256_checksum;
|
||||||
public $directory_lister;
|
public $directory_lister;
|
||||||
|
|
||||||
public function __construct(string $file_path) {
|
public function __construct(string $file_path) {
|
||||||
@ -89,8 +89,7 @@ class Build {
|
|||||||
if (file_exists($sha256_file)) {
|
if (file_exists($sha256_file)) {
|
||||||
$this->sha256_checksum = trim(str_replace(["\r", "\n", "\t"], '', file_get_contents($sha256_file)));
|
$this->sha256_checksum = trim(str_replace(["\r", "\n", "\t"], '', file_get_contents($sha256_file)));
|
||||||
} else {
|
} else {
|
||||||
// Compute SHA256 checksum.
|
$this->sha256_checksum = null;
|
||||||
$this->sha256_checksum = strtoupper(hash_file('sha256', $file_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release cycle.
|
// Release cycle.
|
||||||
|
@ -32,7 +32,7 @@ class BuildsRenderer {
|
|||||||
|
|
||||||
if ($version == 2) {
|
if ($version == 2) {
|
||||||
// If version 2 is requested, skip any .sha256 files and add a checksum key-value entry
|
// If version 2 is requested, skip any .sha256 files and add a checksum key-value entry
|
||||||
if (substr($build->file_name, -7) === '.sha256') {
|
if (endsWith($build->file_name, '.sha256')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$build_data['checksum'] = $build->sha256_checksum;
|
$build_data['checksum'] = $build->sha256_checksum;
|
||||||
|
@ -15,7 +15,7 @@ function handleNotFoundRequest() {
|
|||||||
|
|
||||||
function renderDownloadResponseAsJSON($lister) {
|
function renderDownloadResponseAsJSON($lister) {
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
// Require v=1 to be specified
|
// Require v=1 or v=2 to be specified
|
||||||
if (!isset($_GET['v']) || ($_GET['v'] != '1' && $_GET['v'] != '2')) {
|
if (!isset($_GET['v']) || ($_GET['v'] != '1' && $_GET['v'] != '2')) {
|
||||||
$data = ['error' => 'Invalid version specified. Please provide a supported version using v=1 or v=2.'];
|
$data = ['error' => 'Invalid version specified. Please provide a supported version using v=1 or v=2.'];
|
||||||
echo json_encode( $data );
|
echo json_encode( $data );
|
||||||
|
Loading…
Reference in New Issue
Block a user