Major architectural improvements:
- Merged download and restore into single atomic operation
- Eliminated separate S3DownloadFinished event (redundant)
- Files now transfer directly: S3 → helper container → server → database container
- Removed download progress tracking in favor of unified restore progress
UI/UX improvements:
- Unified restore method selection with visual cards
- Consistent "File Information" display between local and S3 restore
- Single slide-over for all restore operations (removed separate S3 download monitor)
- Better visual feedback with loading states
Security enhancements:
- Added isSafeTmpPath() helper for path traversal protection
- URL decode validation to catch encoded attacks
- Canonical path resolution to prevent symlink attacks
- Comprehensive path validation in all cleanup events
Cleanup improvements:
- S3RestoreJobFinished now handles all cleanup (helper container + all temp files)
- RestoreJobFinished uses new isSafeTmpPath() validation
- CoolifyTask dispatches cleanup events even on job failure
- All cleanup uses non-throwing commands (2>/dev/null || true)
Other improvements:
- S3 storage policy authorization on Show component
- Storage Form properly syncs is_usable state after test
- Removed debug code and improved error handling
- Better command organization and documentation
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.9 KiB
PHP
55 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\Server;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class S3RestoreJobFinished
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct($data)
|
|
{
|
|
$containerName = data_get($data, 'containerName');
|
|
$serverTmpPath = data_get($data, 'serverTmpPath');
|
|
$scriptPath = data_get($data, 'scriptPath');
|
|
$containerTmpPath = data_get($data, 'containerTmpPath');
|
|
$container = data_get($data, 'container');
|
|
$serverId = data_get($data, 'serverId');
|
|
|
|
// Clean up helper container and temporary files
|
|
if (filled($serverId)) {
|
|
$commands = [];
|
|
|
|
// Stop and remove helper container
|
|
if (filled($containerName)) {
|
|
$commands[] = "docker rm -f {$containerName} 2>/dev/null || true";
|
|
}
|
|
|
|
// Clean up downloaded file from server /tmp
|
|
if (isSafeTmpPath($serverTmpPath)) {
|
|
$commands[] = "rm -f {$serverTmpPath} 2>/dev/null || true";
|
|
}
|
|
|
|
// Clean up script from server
|
|
if (isSafeTmpPath($scriptPath)) {
|
|
$commands[] = "rm -f {$scriptPath} 2>/dev/null || true";
|
|
}
|
|
|
|
// Clean up files from database container
|
|
if (filled($container)) {
|
|
if (isSafeTmpPath($containerTmpPath)) {
|
|
$commands[] = "docker exec {$container} rm -f {$containerTmpPath} 2>/dev/null || true";
|
|
}
|
|
if (isSafeTmpPath($scriptPath)) {
|
|
$commands[] = "docker exec {$container} rm -f {$scriptPath} 2>/dev/null || true";
|
|
}
|
|
}
|
|
|
|
instant_remote_process($commands, Server::find($serverId), throwError: false);
|
|
}
|
|
}
|
|
}
|