Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: only set s3DownloadedFile when download actually completes

Andras Bacsai91d752f906d3
diff --git a/app/Events/S3DownloadFinished.php b/app/Events/S3DownloadFinished.php
index ddc2ead30c..32744cfa64 100644
--- a/app/Events/S3DownloadFinished.php
+++ b/app/Events/S3DownloadFinished.php
@@ -15,6 +15,8 @@ class S3DownloadFinished implements ShouldBroadcast
public int|string|null $userId = null;
+ public ?string $downloadPath = null;
+
public function __construct($teamId, $data = null)
{
if (is_null($data)) {
@@ -23,6 +25,7 @@ class S3DownloadFinished implements ShouldBroadcast
// Get userId from event data (the user who triggered the download)
$this->userId = data_get($data, 'userId');
+ $this->downloadPath = data_get($data, 'downloadPath');
$containerName = data_get($data, 'containerName');
$serverId = data_get($data, 'serverId');
@@ -46,4 +49,11 @@ class S3DownloadFinished implements ShouldBroadcast
new PrivateChannel("user.{$this->userId}"),
];
}
+
+ public function broadcastWith(): array
+ {
+ return [
+ 'downloadPath' => $this->downloadPath,
+ ];
+ }
}
diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php
index 9cf11c26c5..ad018a1eb4 100644
--- a/app/Livewire/Project/Database/Import.php
+++ b/app/Livewire/Project/Database/Import.php
@@ -78,9 +78,16 @@ class Import extends Component
];
}
- public function handleS3DownloadFinished(): void
+ public function handleS3DownloadFinished($data): void
{
$this->s3DownloadInProgress = false;
+
+ // Set the downloaded file path from the event data
+ $downloadPath = data_get($data, 'downloadPath');
+ if (filled($downloadPath)) {
+ $this->s3DownloadedFile = $downloadPath;
+ $this->filename = $downloadPath;
+ }
}
public function mount()
@@ -408,9 +415,6 @@ EOD;
'resourceUuid' => $this->resource->uuid,
]);
- $this->s3DownloadedFile = $downloadPath;
- $this->filename = $downloadPath;
-
$this->dispatch('activityMonitor', $activity->id);
$this->dispatch('info', 'Downloading file from S3. This may take a few minutes for large backups...');
} catch (\Throwable $e) {
diff --git a/resources/views/livewire/project/database/import.blade.php b/resources/views/livewire/project/database/import.blade.php
index 2cbfc6943d..b8bed1d444 100644
--- a/resources/views/livewire/project/database/import.blade.php
+++ b/resources/views/livewire/project/database/import.blade.php
@@ -151,7 +151,8 @@
<div class="text-sm text-warning">Downloading from S3... This may take a few minutes for large
backups.</div>
@if ($s3DownloadInProgress)
- <livewire:activity-monitor wire:key="s3-download-{{ $resource->uuid }}" header="S3 Download Progress" :showWaiting="false" />
+ <livewire:activity-monitor wire:key="s3-download-{{ $resource->uuid }}" header="S3 Download Progress"
+ :showWaiting="false" />
@endif
</div>
@@ -176,7 +177,8 @@
</div>
@if ($importRunning)
<div class="container w-full mx-auto">
- <livewire:activity-monitor wire:key="database-restore-{{ $resource->uuid }}" header="Database Restore Output" :showWaiting="false" />
+ <livewire:activity-monitor wire:key="database-restore-{{ $resource->uuid }}" header="Database Restore Output"
+ :showWaiting="false" />
</div>
@endif
@else