Skip to content

Commit 25e53d9

Browse files
committed
Merge branch 'matthewpi/transfer-improvements' of https://github.com/Pterodactyl/Panel into matthewpi/transfer-improvements
2 parents 2ee08a1 + 6fa24d4 commit 25e53d9

File tree

49 files changed

+88
-4473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+88
-4473
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ HASHIDS_SALT=
1919
HASHIDS_LENGTH=8
2020

2121
MAIL_DRIVER=smtp
22-
MAIL_HOST=mailtrap.io
23-
MAIL_PORT=2525
22+
MAIL_HOST=smtp.example.com
23+
MAIL_PORT=25
2424
MAIL_USERNAME=
2525
MAIL_PASSWORD=
2626
MAIL_ENCRYPTION=tls

app/Console/Kernel.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ protected function schedule(Schedule $schedule)
2525
// Execute scheduled commands for servers every minute, as if there was a normal cron running.
2626
$schedule->command('p:schedule:process')->everyMinute()->withoutOverlapping();
2727

28-
// Every 30 minutes, run the backup pruning command so that any abandoned backups can be removed
29-
// from the UI view for the server.
30-
$schedule->command('p:maintenance:prune-backups', [
31-
'--since-minutes' => '30',
32-
])->everyThirtyMinutes();
28+
// Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted.
29+
$pruneAge = config('backups.prune_age', 360); // Defaults to 6 hours (time is in minuteS)
30+
if ($pruneAge > 0) {
31+
$schedule->command('p:maintenance:prune-backups', [
32+
'--since-minutes' => $pruneAge,
33+
])->everyThirtyMinutes();
34+
}
3335

3436
// Every day cleanup any internal backups of service files.
3537
$schedule->command('p:maintenance:clean-service-backups')->daily();

app/Http/Controllers/Api/Client/Servers/FileController.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Pterodactyl\Transformers\Daemon\FileObjectTransformer;
1414
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
1515
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest;
16+
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\PullFileRequest;
1617
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest;
1718
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest;
1819
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest;
@@ -143,10 +144,7 @@ public function download(GetFileContentsRequest $request, Server $server)
143144
*/
144145
public function write(WriteFileContentRequest $request, Server $server): JsonResponse
145146
{
146-
$this->fileRepository->setServer($server)->putContent(
147-
$this->encode($request->get('file')),
148-
$request->getContent()
149-
);
147+
$this->fileRepository->setServer($server)->putContent($request->get('file'), $request->getContent());
150148

151149
return new JsonResponse([], Response::HTTP_NO_CONTENT);
152150
}
@@ -284,16 +282,18 @@ public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse
284282
}
285283

286284
/**
287-
* Encodes a given file name & path in a format that should work for a good majority
288-
* of file names without too much confusing logic.
285+
* Requests that a file be downloaded from a remote location by Wings.
286+
*
287+
* @param $request
288+
* @param \Pterodactyl\Models\Server $server
289+
* @return \Illuminate\Http\JsonResponse
289290
*
290-
* @param string $path
291-
* @return string
291+
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
292292
*/
293-
private function encode(string $path): string
293+
public function pull(PullFileRequest $request, Server $server): JsonResponse
294294
{
295-
return Collection::make(explode('/', rawurldecode($path)))->map(function ($value) {
296-
return rawurlencode($value);
297-
})->join('/');
295+
$this->fileRepository->setServer($server)->pull($request->input('url'), $request->input('directory'));
296+
297+
return new JsonResponse([], Response::HTTP_NO_CONTENT);
298298
}
299299
}

app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(BackupRepository $repository, BackupManager $backupM
5252
public function __invoke(Request $request, string $backup)
5353
{
5454
// Get the size query parameter.
55-
$size = (int)$request->query('size');
55+
$size = (int) $request->query('size');
5656
if (empty($size)) {
5757
throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.');
5858
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Files;
4+
5+
use Pterodactyl\Models\Permission;
6+
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
7+
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
8+
9+
class PullFileRequest extends ClientApiRequest implements ClientPermissionsRequest
10+
{
11+
/**
12+
* @return string
13+
*/
14+
public function permission(): string
15+
{
16+
return Permission::ACTION_FILE_CREATE;
17+
}
18+
19+
/**
20+
* @return string[]
21+
*/
22+
public function rules(): array
23+
{
24+
return [
25+
'url' => 'required|string|url',
26+
'directory' => 'sometimes|nullable|string',
27+
];
28+
}
29+
}

app/Repositories/Wings/DaemonBackupRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Repositories\Wings;
44

5+
use Illuminate\Support\Arr;
56
use Webmozart\Assert\Assert;
67
use Pterodactyl\Models\Backup;
78
use Pterodactyl\Models\Server;
@@ -48,7 +49,7 @@ public function backup(Backup $backup): ResponseInterface
4849
'json' => [
4950
'adapter' => $this->adapter ?? config('backups.default'),
5051
'uuid' => $backup->uuid,
51-
'ignored_files' => $backup->ignored_files,
52+
'ignore' => implode('\n', $backup->ignored_files),
5253
],
5354
]
5455
);

app/Repositories/Wings/DaemonFileRepository.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getContent(string $path, int $notLargerThan = null): string
3737
throw new DaemonConnectionException($exception);
3838
}
3939

40-
$length = (int) $response->getHeader('Content-Length')[0] ?? 0;
40+
$length = (int)$response->getHeader('Content-Length')[0] ?? 0;
4141

4242
if ($notLargerThan && $length > $notLargerThan) {
4343
throw new FileSizeTooLargeException;
@@ -297,4 +297,29 @@ public function chmodFiles(?string $root, array $files): ResponseInterface
297297
throw new DaemonConnectionException($exception);
298298
}
299299
}
300+
301+
/**
302+
* Pulls a file from the given URL and saves it to the disk.
303+
*
304+
* @param string $url
305+
* @param string|null $directory
306+
* @return \Psr\Http\Message\ResponseInterface
307+
*
308+
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
309+
*/
310+
public function pull(string $url, ?string $directory): ResponseInterface
311+
{
312+
Assert::isInstanceOf($this->server, Server::class);
313+
314+
try {
315+
return $this->getHttpClient()->post(
316+
sprintf('/api/servers/%s/files/pull', $this->server->uuid),
317+
[
318+
'json' => ['url' => $url, 'directory' => $directory ?? '/'],
319+
]
320+
);
321+
} catch (TransferException $exception) {
322+
throw new DaemonConnectionException($exception);
323+
}
324+
}
300325
}

app/Services/Backups/InitiateBackupService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function handle(Server $server, string $name = null, bool $override = fal
117117
}
118118

119119
// Check if the server has reached or exceeded it's backup limit
120-
if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
120+
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
121121
// Do not allow the user to continue if this server is already at its limit and can't override.
122-
if (!$override || $server->backup_limit <= 0) {
122+
if (! $override || $server->backup_limit <= 0) {
123123
throw new TooManyBackupsException($server->backup_limit);
124124
}
125125

config/backups.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// uses to upload backups to S3 storage. Value is in minutes, so this would default to an hour.
1313
'presigned_url_lifespan' => env('BACKUP_PRESIGNED_URL_LIFESPAN', 60),
1414

15+
// The time to wait before automatically failing a backup, time is in minutes and defaults
16+
// to 6 hours. To disable this feature, set the value to `0`.
17+
'prune_age' => env('BACKUP_PRUNE_AGE', 360),
18+
1519
'disks' => [
1620
// There is no configuration for the local disk for Wings. That configuration
1721
// is determined by the Daemon configuration, and not the Panel.

database/seeds/eggs/minecraft/egg-sponge--sponge-vanilla.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"name": "Sponge Version",
2929
"description": "The version of SpongeVanilla to download and use.",
3030
"env_variable": "SPONGE_VERSION",
31-
"default_value": "1.11.2-6.1.0-BETA-21",
31+
"default_value": "1.12.2-7.3.0",
3232
"user_viewable": true,
3333
"user_editable": false,
3434
"rules": "required|regex:\/^([a-zA-Z0-9.\\-_]+)$\/"

0 commit comments

Comments
 (0)