mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Add changes from upstream (#2076)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
@@ -83,15 +83,21 @@ class BackupController extends ClientApiController
|
||||
// how best to allow a user to create a backup that is locked without also preventing
|
||||
// them from just filling up a server with backups that can never be deleted?
|
||||
if ($request->user()->can(SubuserPermission::BackupDelete, $server)) {
|
||||
$action->setIsLocked((bool) $request->input('is_locked'));
|
||||
$action->setIsLocked($request->boolean('is_locked'));
|
||||
}
|
||||
|
||||
$backup = $action->handle($server, $request->input('name'));
|
||||
$backup = Activity::event('server:backup.start')->transaction(function ($log) use ($action, $server, $request) {
|
||||
$server->backups()->lockForUpdate();
|
||||
|
||||
Activity::event('server:backup.start')
|
||||
->subject($backup)
|
||||
->property(['name' => $backup->name, 'locked' => (bool) $request->input('is_locked')])
|
||||
->log();
|
||||
$backup = $action->handle($server, $request->input('name'));
|
||||
|
||||
$log->subject($backup)->property([
|
||||
'name' => $backup->name,
|
||||
'locked' => $request->boolean('is_locked'),
|
||||
]);
|
||||
|
||||
return $backup;
|
||||
});
|
||||
|
||||
return $this->fractal->item($backup)
|
||||
->transformWith($this->getTransformer(BackupTransformer::class))
|
||||
|
||||
@@ -59,12 +59,15 @@ class DatabaseController extends ClientApiController
|
||||
*/
|
||||
public function store(StoreDatabaseRequest $request, Server $server): array
|
||||
{
|
||||
$database = $this->deployDatabaseService->handle($server, $request->validated());
|
||||
$database = Activity::event('server:database.create')->transaction(function ($log) use ($request, $server) {
|
||||
$server->databases()->lockForUpdate();
|
||||
|
||||
Activity::event('server:database.create')
|
||||
->subject($database)
|
||||
->property('name', $database->database)
|
||||
->log();
|
||||
$database = $this->deployDatabaseService->handle($server, $request->validated());
|
||||
|
||||
$log->subject($database)->property('name', $database->database);
|
||||
|
||||
return $database;
|
||||
});
|
||||
|
||||
return $this->fractal->item($database)
|
||||
->parseIncludes(['password'])
|
||||
|
||||
@@ -107,16 +107,19 @@ class NetworkAllocationController extends ClientApiController
|
||||
*/
|
||||
public function store(NewAllocationRequest $request, Server $server): array
|
||||
{
|
||||
if ($server->allocations()->count() >= $server->allocation_limit) {
|
||||
throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.');
|
||||
}
|
||||
$allocation = Activity::event('server:allocation.create')->transaction(function ($log) use ($server) {
|
||||
$server->allocations()->lockForUpdate();
|
||||
|
||||
$allocation = $this->assignableAllocationService->handle($server);
|
||||
if ($server->allocations->count() >= $server->allocation_limit) {
|
||||
throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.');
|
||||
}
|
||||
|
||||
Activity::event('server:allocation.create')
|
||||
->subject($allocation)
|
||||
->property('allocation', $allocation->address)
|
||||
->log();
|
||||
$allocation = $this->assignableAllocationService->handle($server);
|
||||
|
||||
$log->subject($allocation)->property('allocation', $allocation->address);
|
||||
|
||||
return $allocation;
|
||||
});
|
||||
|
||||
return $this->fractal->item($allocation)
|
||||
->transformWith($this->getTransformer(AllocationTransformer::class))
|
||||
|
||||
@@ -131,7 +131,7 @@ class BackupRemoteUploadController extends Controller
|
||||
*/
|
||||
private function getConfiguredMaxPartSize(): int
|
||||
{
|
||||
$maxPartSize = (int) config('backups.max_part_size', self::DEFAULT_MAX_PART_SIZE);
|
||||
$maxPartSize = config('backups.max_part_size', self::DEFAULT_MAX_PART_SIZE);
|
||||
if ($maxPartSize <= 0) {
|
||||
$maxPartSize = self::DEFAULT_MAX_PART_SIZE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user