Fix some file management bugs, closes #621
This commit is contained in:
parent
ffc8d4875f
commit
0ec5a4e08c
|
@ -95,11 +95,10 @@ class FileActionsController extends Controller
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return \Illuminate\View\View
|
* @return \Illuminate\View\View
|
||||||
*
|
*
|
||||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @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');
|
$server = $request->attributes->get('server');
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ class RemoteRequestController extends Controller
|
||||||
$this->repository->setNode($server->node_id)
|
$this->repository->setNode($server->node_id)
|
||||||
->setAccessServer($server->uuid)
|
->setAccessServer($server->uuid)
|
||||||
->setAccessToken($request->attributes->get('server_token'))
|
->setAccessToken($request->attributes->get('server_token'))
|
||||||
->putContent($request->input('file'), $request->input('contents'));
|
->putContent($request->input('file'), $request->input('contents') ?? '');
|
||||||
|
|
||||||
return response('', 204);
|
return response('', 204);
|
||||||
} catch (RequestException $exception) {
|
} catch (RequestException $exception) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Pterodactyl\Http\Requests\Server;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use Illuminate\Contracts\Config\Repository;
|
use Illuminate\Contracts\Config\Repository;
|
||||||
use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException;
|
use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface;
|
||||||
use Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException;
|
use Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException;
|
||||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
@ -80,8 +81,13 @@ class UpdateFileContentsFormRequest extends ServerFormRequest
|
||||||
->setAccessToken($token)
|
->setAccessToken($token)
|
||||||
->getFileStat($this->route()->parameter('file'));
|
->getFileStat($this->route()->parameter('file'));
|
||||||
} catch (RequestException $exception) {
|
} catch (RequestException $exception) {
|
||||||
|
switch ($exception->getCode()) {
|
||||||
|
case 404:
|
||||||
|
throw new NotFoundHttpException;
|
||||||
|
default:
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $stats->file || ! in_array($stats->mime, $config->get('pterodactyl.files.editable'))) {
|
if (! $stats->file || ! in_array($stats->mime, $config->get('pterodactyl.files.editable'))) {
|
||||||
throw new FileTypeNotEditableException(trans('server.files.exceptions.invalid_mime'));
|
throw new FileTypeNotEditableException(trans('server.files.exceptions.invalid_mime'));
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
<td data-identifier="name" data-name="{{ rawurlencode($file['entry']) }}" data-path="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}@endif/">
|
<td data-identifier="name" data-name="{{ rawurlencode($file['entry']) }}" data-path="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}@endif/">
|
||||||
@if(in_array($file['mime'], $editableMime))
|
@if(in_array($file['mime'], $editableMime))
|
||||||
@can('edit-files', $server)
|
@can('edit-files', $server)
|
||||||
<a href="/server/{{ $server->uuidShort }}/files/edit/@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}" class="edit_file">{{ $file['entry'] }}</a>
|
<a href="/server/{{ $server->uuidShort }}/files/edit/@if($file['directory'] !== ''){{ $file['directory'] }}/@endif{{ $file['entry'] }}" class="edit_file">{{ $file['entry'] }}</a>
|
||||||
@else
|
@else
|
||||||
{{ $file['entry'] }}
|
{{ $file['entry'] }}
|
||||||
@endcan
|
@endcan
|
||||||
|
|
|
@ -52,7 +52,7 @@ Route::group(['prefix' => 'databases'], function () {
|
||||||
Route::group(['prefix' => 'files'], function () {
|
Route::group(['prefix' => 'files'], function () {
|
||||||
Route::get('/', 'Files\FileActionsController@index')->name('server.files.index');
|
Route::get('/', 'Files\FileActionsController@index')->name('server.files.index');
|
||||||
Route::get('/add', 'Files\FileActionsController@create')->name('server.files.add');
|
Route::get('/add', 'Files\FileActionsController@create')->name('server.files.add');
|
||||||
Route::get('/edit/{file}', 'Files\FileActionsController@update')->name('server.files.edit')->where('file', '.*');
|
Route::get('/edit/{file}', 'Files\FileActionsController@view')->name('server.files.edit')->where('file', '.*');
|
||||||
Route::get('/download/{file}', 'Files\DownloadController@index')->name('server.files.edit')->where('file', '.*');
|
Route::get('/download/{file}', 'Files\DownloadController@index')->name('server.files.edit')->where('file', '.*');
|
||||||
|
|
||||||
Route::post('/directory-list', 'Files\RemoteRequestController@directory')->name('server.files.directory-list');
|
Route::post('/directory-list', 'Files\RemoteRequestController@directory')->name('server.files.directory-list');
|
||||||
|
|
Loading…
Reference in New Issue