- Add null checks for server instances in restore events to prevent errors - Escape S3 credentials to prevent command injection vulnerabilities - Fix file upload clearing custom location to prevent UI confusion - Optimize isSafeTmpPath helper by avoiding redundant dirname calls - Remove unnecessary --rm flag from long-running S3 restore container - Prioritize uploaded files over custom location in import logic - Add comprehensive unit tests for restore event null server handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\Server;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class RestoreJobFinished
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct($data)
|
|
{
|
|
$scriptPath = data_get($data, 'scriptPath');
|
|
$tmpPath = data_get($data, 'tmpPath');
|
|
$container = data_get($data, 'container');
|
|
$serverId = data_get($data, 'serverId');
|
|
|
|
if (filled($container) && filled($serverId)) {
|
|
$commands = [];
|
|
|
|
if (isSafeTmpPath($scriptPath)) {
|
|
$commands[] = "docker exec {$container} sh -c 'rm {$scriptPath} 2>/dev/null || true'";
|
|
}
|
|
|
|
if (isSafeTmpPath($tmpPath)) {
|
|
$commands[] = "docker exec {$container} sh -c 'rm {$tmpPath} 2>/dev/null || true'";
|
|
}
|
|
|
|
if (! empty($commands)) {
|
|
$server = Server::find($serverId);
|
|
if ($server) {
|
|
instant_remote_process($commands, $server, throwError: false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|