mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 07:27:47 +00:00
This commit is contained in:
parent
e9fc6b2335
commit
5d3a512203
20 changed files with 1651 additions and 101 deletions
|
|
@ -33,16 +33,25 @@ class FirmwareDownloadJob implements ShouldQueue
|
|||
|
||||
try {
|
||||
$filename = "FW{$this->firmware->version_tag}.bin";
|
||||
Http::sink(storage_path("app/public/firmwares/$filename"))
|
||||
->get($this->firmware->url);
|
||||
$response = Http::get($this->firmware->url);
|
||||
|
||||
if (! $response->successful()) {
|
||||
throw new Exception('HTTP request failed with status: '.$response->status());
|
||||
}
|
||||
|
||||
// Save the response content to file
|
||||
Storage::disk('public')->put("firmwares/$filename", $response->body());
|
||||
|
||||
// Only update storage location if download was successful
|
||||
$this->firmware->update([
|
||||
'storage_location' => "firmwares/$filename",
|
||||
]);
|
||||
} catch (ConnectionException $e) {
|
||||
Log::error('Firmware download failed: '.$e->getMessage());
|
||||
// Don't update storage_location on failure
|
||||
} catch (Exception $e) {
|
||||
Log::error('An unexpected error occurred: '.$e->getMessage());
|
||||
// Don't update storage_location on failure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue