initial commit
This commit is contained in:
35
app/Console/Commands/PurgeExpiredIsoUploadsCommand.php
Normal file
35
app/Console/Commands/PurgeExpiredIsoUploadsCommand.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\CustomerIsoUpload;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PurgeExpiredIsoUploadsCommand extends Command
|
||||
{
|
||||
protected $signature = 'hosting:purge-iso-uploads';
|
||||
|
||||
protected $description = 'Remove expired customer ISO uploads from Proxmox storage';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$expired = CustomerIsoUpload::query()
|
||||
->where('expires_at', '<=', now())
|
||||
->get();
|
||||
|
||||
foreach ($expired as $upload) {
|
||||
try {
|
||||
// Proxmox delete via storage API when upload service is wired
|
||||
Log::info('ISO upload expired', ['volid' => $upload->volid, 'user_id' => $upload->user_id]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('ISO purge failed', ['id' => $upload->id, 'error' => $e->getMessage()]);
|
||||
}
|
||||
$upload->delete();
|
||||
}
|
||||
|
||||
$this->info("Purged {$expired->count()} expired ISO upload(s).");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user