mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 03:59:08 -05:00
refactor: staff backup controller
This commit is contained in:
@@ -46,8 +46,8 @@ class BackupController extends Controller
|
||||
|
||||
$data['backups'] = [];
|
||||
|
||||
foreach (\config('backup.backup.destination.disks') as $disk_name) {
|
||||
$disk = Storage::disk($disk_name);
|
||||
foreach (\config('backup.backup.destination.disks') as $diskName) {
|
||||
$disk = Storage::disk($diskName);
|
||||
$adapter = $disk->getDriver()->getAdapter();
|
||||
// make an array of backup files, with their filesize and creation date
|
||||
foreach ($disk->allFiles() as $k => $f) {
|
||||
@@ -58,7 +58,7 @@ class BackupController extends Controller
|
||||
'file_name' => \str_replace('backups/', '', $f),
|
||||
'file_size' => $disk->size($f),
|
||||
'last_modified' => $disk->lastModified($f),
|
||||
'disk' => $disk_name,
|
||||
'disk' => $diskName,
|
||||
'download' => $adapter instanceof Local,
|
||||
];
|
||||
}
|
||||
@@ -193,14 +193,14 @@ class BackupController extends Controller
|
||||
\abort_unless($user->group->is_owner, 403);
|
||||
|
||||
$disk = Storage::disk($request->input('disk'));
|
||||
$file_name = $request->input('file_name');
|
||||
$fileName = $request->input('file_name');
|
||||
$adapter = $disk->getDriver()->getAdapter();
|
||||
|
||||
if ($adapter instanceof Local) {
|
||||
$storage_path = $disk->getDriver()->getAdapter()->getPathPrefix();
|
||||
$storagePath = $disk->getDriver()->getAdapter()->getPathPrefix();
|
||||
|
||||
if ($disk->exists($file_name)) {
|
||||
return \response()->download($storage_path.$file_name);
|
||||
if ($disk->exists($fileName)) {
|
||||
return \response()->download($storagePath.$fileName);
|
||||
}
|
||||
|
||||
return \abort(404, \trans('backup.backup_doesnt_exist'));
|
||||
@@ -222,12 +222,12 @@ class BackupController extends Controller
|
||||
\abort_unless($user->group->is_owner, 403);
|
||||
|
||||
$disk = Storage::disk($request->input('disk'));
|
||||
$file_name = $request->input('file_name');
|
||||
$fileName = $request->input('file_name');
|
||||
$adapter = $disk->getDriver()->getAdapter();
|
||||
|
||||
if ($adapter instanceof Local) {
|
||||
if ($disk->exists($file_name)) {
|
||||
$disk->delete($file_name);
|
||||
if ($disk->exists($fileName)) {
|
||||
$disk->delete($fileName);
|
||||
|
||||
return self::MESSAGE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user