mirror of
https://github.com/ConvoyPanel/panel.git
synced 2026-05-10 17:15:50 +08:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Convoy\Services\Isos;
|
|
|
|
use Carbon\Carbon;
|
|
use Closure;
|
|
use Convoy\Models\ISO;
|
|
use Convoy\Repositories\Proxmox\Server\ProxmoxActivityRepository;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Str;
|
|
|
|
class IsoMonitorService
|
|
{
|
|
public function __construct(private ProxmoxActivityRepository $repository)
|
|
{
|
|
}
|
|
|
|
public function checkDownloadProgress(ISO $iso, string $upid, ?Closure $callback = null): void
|
|
{
|
|
$status = $this->repository->setNode($iso->node)->getStatus($upid);
|
|
|
|
if (Arr::get($status, 'status') === 'running') {
|
|
if ($callback) {
|
|
$callback();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (Str::lower(Arr::get($status, 'exitstatus')) === 'ok') {
|
|
$iso->update([
|
|
'is_successful' => true,
|
|
'completed_at' => Carbon::now(),
|
|
]);
|
|
} else {
|
|
$iso->update([
|
|
'is_successful' => false,
|
|
'completed_at' => Carbon::now(),
|
|
]);
|
|
}
|
|
}
|
|
}
|