diff --git a/app/Http/Controllers/Server/Files/FileActionsController.php b/app/Http/Controllers/Server/Files/FileActionsController.php index 9c5b77ea1..08e6fa881 100644 --- a/app/Http/Controllers/Server/Files/FileActionsController.php +++ b/app/Http/Controllers/Server/Files/FileActionsController.php @@ -95,11 +95,10 @@ class FileActionsController extends Controller * @param string $file * @return \Illuminate\View\View * - * @throws \Illuminate\Auth\Access\AuthorizationException - * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function update(UpdateFileContentsFormRequest $request, string $uuid, string $file): View + public function view(UpdateFileContentsFormRequest $request, string $uuid, string $file): View { $server = $request->attributes->get('server'); diff --git a/app/Http/Controllers/Server/Files/RemoteRequestController.php b/app/Http/Controllers/Server/Files/RemoteRequestController.php index 5deba5f95..81dba4cab 100644 --- a/app/Http/Controllers/Server/Files/RemoteRequestController.php +++ b/app/Http/Controllers/Server/Files/RemoteRequestController.php @@ -101,7 +101,7 @@ class RemoteRequestController extends Controller $this->repository->setNode($server->node_id) ->setAccessServer($server->uuid) ->setAccessToken($request->attributes->get('server_token')) - ->putContent($request->input('file'), $request->input('contents')); + ->putContent($request->input('file'), $request->input('contents') ?? ''); return response('', 204); } catch (RequestException $exception) { diff --git a/app/Http/Requests/Server/UpdateFileContentsFormRequest.php b/app/Http/Requests/Server/UpdateFileContentsFormRequest.php index 051e78dbd..d2337ba6a 100644 --- a/app/Http/Requests/Server/UpdateFileContentsFormRequest.php +++ b/app/Http/Requests/Server/UpdateFileContentsFormRequest.php @@ -12,6 +12,7 @@ namespace Pterodactyl\Http\Requests\Server; use GuzzleHttp\Exception\RequestException; use Illuminate\Contracts\Config\Repository; use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface; use Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException; use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; @@ -80,7 +81,12 @@ class UpdateFileContentsFormRequest extends ServerFormRequest ->setAccessToken($token) ->getFileStat($this->route()->parameter('file')); } catch (RequestException $exception) { - throw new DaemonConnectionException($exception); + switch ($exception->getCode()) { + case 404: + throw new NotFoundHttpException; + default: + throw new DaemonConnectionException($exception); + } } if (! $stats->file || ! in_array($stats->mime, $config->get('pterodactyl.files.editable'))) { diff --git a/resources/themes/pterodactyl/server/files/list.blade.php b/resources/themes/pterodactyl/server/files/list.blade.php index d5df9984a..bbe2b24d8 100644 --- a/resources/themes/pterodactyl/server/files/list.blade.php +++ b/resources/themes/pterodactyl/server/files/list.blade.php @@ -137,7 +137,7 @@