Skip to content

Commit ec7bb22

Browse files
committed
Merge branch 'develop' of https://github.com/Pterodactyl/Panel into develop
2 parents 7657d01 + 86c9743 commit ec7bb22

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

app/Jobs/Schedule/RunTaskJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function handle(
6969
$commandRepository->setServer($server)->send($this->task->payload);
7070
break;
7171
case 'backup':
72-
$backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null);
72+
$backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null, true);
7373
break;
7474
default:
7575
throw new InvalidArgumentException('Cannot run a task that points to a non-existent action.');

app/Services/Backups/InitiateBackupService.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
1414
use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException;
1515
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
16+
use Pterodactyl\Services\Backups\DeleteBackupService;
1617

1718
class InitiateBackupService
1819
{
@@ -41,24 +42,32 @@ class InitiateBackupService
4142
*/
4243
private $backupManager;
4344

45+
/**
46+
* @var \Pterodactyl\Services\Backups\DeleteBackupService
47+
*/
48+
private $deleteBackupService;
49+
4450
/**
4551
* InitiateBackupService constructor.
4652
*
4753
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
4854
* @param \Illuminate\Database\ConnectionInterface $connection
4955
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository
56+
* @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService
5057
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
5158
*/
5259
public function __construct(
5360
BackupRepository $repository,
5461
ConnectionInterface $connection,
5562
DaemonBackupRepository $daemonBackupRepository,
63+
DeleteBackupService $deleteBackupService,
5664
BackupManager $backupManager
5765
) {
5866
$this->repository = $repository;
5967
$this->connection = $connection;
6068
$this->daemonBackupRepository = $daemonBackupRepository;
6169
$this->backupManager = $backupManager;
70+
$this->deleteBackupService = $deleteBackupService;
6271
}
6372

6473
/**
@@ -96,13 +105,8 @@ public function setIgnoredFiles(?array $ignored)
96105
* @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException
97106
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
98107
*/
99-
public function handle(Server $server, string $name = null): Backup
108+
public function handle(Server $server, string $name = null, bool $override = false): Backup
100109
{
101-
// Do not allow the user to continue if this server is already at its limit.
102-
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
103-
throw new TooManyBackupsException($server->backup_limit);
104-
}
105-
106110
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10);
107111
if ($previous->count() >= 2) {
108112
throw new TooManyRequestsHttpException(
@@ -111,6 +115,18 @@ public function handle(Server $server, string $name = null): Backup
111115
);
112116
}
113117

118+
// Check if the server has reached or exceeded it's backup limit
119+
if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
120+
// Do not allow the user to continue if this server is already at its limit and can't override.
121+
if (!$override || $server->backup_limit <= 0) {
122+
throw new TooManyBackupsException($server->backup_limit);
123+
}
124+
125+
// Remove oldest backup
126+
$oldestBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first();
127+
$this->deleteBackupService->handle($oldestBackup);
128+
}
129+
114130
return $this->connection->transaction(function () use ($server, $name) {
115131
/** @var \Pterodactyl\Models\Backup $backup */
116132
$backup = $this->repository->create([

resources/scripts/components/server/databases/CreateDatabaseButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const schema = object().shape({
2424
.matches(/^[A-Za-z0-9_\-.]{3,48}$/, 'Database name should only contain alphanumeric characters, underscores, dashes, and/or periods.'),
2525
connectionsFrom: string()
2626
.required('A connection value must be provided.')
27-
.matches(/^([1-9]{1,3}|%)(\.([0-9]{1,3}|%))?(\.([0-9]{1,3}|%))?(\.([0-9]{1,3}|%))?$/, 'A valid connection address must be provided.'),
27+
.matches(/^([0-9]{1,3}|%)(\.([0-9]{1,3}|%))?(\.([0-9]{1,3}|%))?(\.([0-9]{1,3}|%))?$/, 'A valid connection address must be provided.'),
2828
});
2929

3030
export default () => {

resources/scripts/components/server/databases/DatabaseRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default ({ database, className }: Props) => {
131131
</div>
132132
</Can>
133133
<div css={tw`mt-6`}>
134-
<Label>JBDC Connection String</Label>
134+
<Label>JDBC Connection String</Label>
135135
<CopyOnClick text={`jdbc:mysql://${database.username}:${database.password}@${database.connectionString}/${database.name}`}>
136136
<Input
137137
type={'text'}

resources/scripts/components/server/schedules/TaskDetailsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
9191
<Label>Ignored Files</Label>
9292
<FormikFieldWrapper
9393
name={'payload'}
94-
description={'Optional. Include the files and folders to be excluded in this backup. By default, the contents of your .pteroignore file will be used.'}
94+
description={'Optional. Include the files and folders to be excluded in this backup. By default, the contents of your .pteroignore file will be used. If you have reached your backup limit, the oldest backup will be rotated.'}
9595
>
9696
<FormikField as={Textarea} name={'payload'} rows={6} />
9797
</FormikFieldWrapper>

resources/views/admin/nodes/view/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<td data-attr="info-system"><i class="fa fa-refresh fa-fw fa-spin"></i></td>
5252
</tr>
5353
<tr>
54-
<td>Total CPU Cores</td>
54+
<td>Total CPU Threads</td>
5555
<td data-attr="info-cpus"><i class="fa fa-refresh fa-fw fa-spin"></i></td>
5656
</tr>
5757
</table>

0 commit comments

Comments
 (0)