mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 14:06:15 +00:00
Edit & Download (local) Backups (#436)
* Allow editing of backups * pint updates * setup of backup download * allow download for local backup files * delete uploaded files on delete of BackupFile * pint updates * S3 upload & download fixes * Deletion of backup files * support $ARCH selector for s3 installation * delete files when deleting backup * fixed ui issue * adjustment * Use system temp path for downloads --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
39
app/Actions/Database/ManageBackupFile.php
Normal file
39
app/Actions/Database/ManageBackupFile.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Enums\BackupFileStatus;
|
||||
use App\Models\BackupFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Throwable;
|
||||
|
||||
class ManageBackupFile
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function download(BackupFile $file): StreamedResponse
|
||||
{
|
||||
$localFilename = "backup_{$file->id}_{$file->name}.zip";
|
||||
|
||||
if (! Storage::disk('backups')->exists($localFilename)) {
|
||||
$file->backup->server->ssh()->download(
|
||||
Storage::disk('backups')->path($localFilename),
|
||||
$file->path()
|
||||
);
|
||||
}
|
||||
|
||||
return Storage::disk('backups')->download($localFilename, $file->name.'.zip');
|
||||
}
|
||||
|
||||
public function delete(BackupFile $file): void
|
||||
{
|
||||
$file->status = BackupFileStatus::DELETING;
|
||||
$file->save();
|
||||
|
||||
dispatch(function () use ($file) {
|
||||
$file->deleteFile();
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user