Fix LMS plugin availability check. As I removed the download by ID, this needs a tweak on the UI/JS side.

This commit is contained in:
Michael Herger
2021-04-17 06:31:28 +02:00
parent 36571d3dad
commit f96d06912f
21 changed files with 68 additions and 58 deletions

View File

@@ -13,7 +13,7 @@ use constant FIRMWARE_POLL_INTERVAL => 3600 * (5 + rand());
use constant GITHUB_RELEASES_URI => "https://api.github.com/repos/sle118/squeezelite-esp32/releases";
use constant GITHUB_ASSET_URI => GITHUB_RELEASES_URI . "/assets/";
use constant GITHUB_DOWNLOAD_URI => "https://github.com/sle118/squeezelite-esp32/releases/download/";
use constant ESP32_STATUS_URI => "/status.json";
use constant ESP32_STATUS_URI => "http://%s/status.json";
my $FW_DOWNLOAD_REGEX = qr|plugins/SqueezeESP32/firmware/([-a-z0-9-/.]+\.bin)$|i;
my $FW_FILENAME_REGEX = qr/^squeezelite-esp32-.*\.bin(\.tmp)?$/;
@@ -61,7 +61,7 @@ sub initFirmwareDownload {
{
timeout => 10
}
)->get('http://' . $client->ip . ESP32_STATUS_URI);
)->get(sprintf(ESP32_STATUS_URI, $client->ip));
Slim::Utils::Timers::setTimer($client, Time::HiRes::time() + FIRMWARE_POLL_INTERVAL, \&initFirmwareDownload);
}
@@ -128,6 +128,15 @@ sub handleFirmwareDownload {
return $_errorDownloading->(undef, 'Invalid request', $request->uri, 400);
}
# this is the magic number used on the client to figure out whether the plugin does support download proxying
if ($path eq '-check.bin' && $request->method eq 'HEAD') {
$response->code(204);
$response->header('Access-Control-Allow-Origin' => '*');
$httpClient->send_response($response);
return Slim::Web::HTTP::closeHTTPSocket($httpClient);
}
main::INFOLOG && $log->is_info && $log->info("Requesting firmware from: $path");
downloadFirmwareFile(sub {