Backup Rotation - Minor changes

This commit is contained in:
Gonzalo Chavez 2020-11-11 10:52:28 -03:00
parent 1eaf486eaa
commit 7b8322e9c9
2 changed files with 9 additions and 9 deletions

View file

@ -116,16 +116,16 @@ class InitiateBackupService
} }
// Check if the server has reached or exceeded it's backup limit // Check if the server has reached or exceeded it's backup limit
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) { if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
if($override) { // Do not allow the user to continue if this server is already at its limit and can't override.
// Remove latest backup if (!$override || $server->backup_limit <= 0) {
$last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
$this->deleteBackupService->handle($last_backup);
} else {
// Do not allow the user to continue if this server is already at its limit.
throw new TooManyBackupsException($server->backup_limit); throw new TooManyBackupsException($server->backup_limit);
} }
}
// Remove latest backup
$lastBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first();
$this->deleteBackupService->handle($lastBackup);
}
return $this->connection->transaction(function () use ($server, $name) { return $this->connection->transaction(function () use ($server, $name) {
/** @var \Pterodactyl\Models\Backup $backup */ /** @var \Pterodactyl\Models\Backup $backup */

View file

@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
<Label>Ignored Files</Label> <Label>Ignored Files</Label>
<FormikFieldWrapper <FormikFieldWrapper
name={'payload'} name={'payload'}
description={'Optional. Include the files and folders to be excluded in this backup. By default, the contents of your .pteroignore file will be used.\nIf you have reached your backup limit, the oldest backup will be rotated.'} 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.'}
> >
<FormikField as={Textarea} name={'payload'} rows={6} /> <FormikField as={Textarea} name={'payload'} rows={6} />
</FormikFieldWrapper> </FormikFieldWrapper>