Fix file writing (#1218)

This commit is contained in:
Boy132 2025-04-04 14:38:08 +02:00 committed by GitHub
parent 20f271041a
commit 3639d7ccec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -70,10 +70,8 @@ class EditFiles extends Page
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->icon('tabler-device-floppy')
->keyBindings('mod+shift+s')
->action(function (array $data) {
$this->getDaemonFileRepository()
->putContent($this->path, $data['editor'] ?? '');
->action(function () {
$this->getDaemonFileRepository()->putContent($this->path, $this->data['editor'] ?? '');
Activity::event('server:file.write')
->property('file', $this->path)
@ -92,10 +90,8 @@ class EditFiles extends Page
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->icon('tabler-device-floppy')
->keyBindings('mod+s')
->action(function (array $data) {
$this->getDaemonFileRepository()
->putContent($this->path, $data['editor'] ?? '');
->action(function () {
$this->getDaemonFileRepository()->putContent($this->path, $this->data['editor'] ?? '');
Activity::event('server:file.write')
->property('file', $this->path)
@ -127,8 +123,7 @@ class EditFiles extends Page
->showPlaceholder(false)
->default(function () {
try {
return $this->getDaemonFileRepository()
->getContent($this->path, config('panel.files.max_edit_size'));
return $this->getDaemonFileRepository()->getContent($this->path, config('panel.files.max_edit_size'));
} catch (FileSizeTooLargeException) {
AlertBanner::make()
->title('File too large!')
@ -136,6 +131,7 @@ class EditFiles extends Page
->danger()
->closable()
->send();
$this->redirect(ListFiles::getUrl());
} catch (FileNotFoundException) {
AlertBanner::make()
@ -144,6 +140,7 @@ class EditFiles extends Page
->danger()
->closable()
->send();
$this->redirect(ListFiles::getUrl());
} catch (FileNotEditableException) {
AlertBanner::make()
@ -152,6 +149,7 @@ class EditFiles extends Page
->danger()
->closable()
->send();
$this->redirect(ListFiles::getUrl());
}
})