An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(LocalFileVolume): add binary file detection and update UI logic
Andras Bacsai595370df926b
diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.phpindex 2c223be779..d96f7125e1 100644--- a/app/Models/LocalFileVolume.php+++ b/app/Models/LocalFileVolume.php@@ -3,6 +3,7 @@namespace App\Models;use App\Events\FileStorageChanged;+use Illuminate\Database\Eloquent\Casts\Attribute;use Illuminate\Database\Eloquent\Factories\HasFactory;class LocalFileVolume extends BaseModel@@ -11,6 +12,8 @@ class LocalFileVolume extends BaseModelprotected $guarded = [];+ public $appends = ['is_binary'];+protected static function booted(){static::created(function (LocalFileVolume $fileVolume) {@@ -19,6 +22,15 @@ class LocalFileVolume extends BaseModel});}+ protected function isBinary(): Attribute+ {+ return Attribute::make(+ get: function () {+ return $this->content === '[binary file]';+ }+ );+ }+public function service(){return $this->morphTo('resource');@@ -44,6 +56,10 @@ class LocalFileVolume extends BaseModel$isFile = instant_remote_process(["test -f $path && echo OK || echo NOK"], $server);if ($isFile === 'OK') {$content = instant_remote_process(["cat $path"], $server, false);+ // Check if content contains binary data by looking for null bytes or non-printable characters+ if (str_contains($content, "\0") || preg_match('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', $content)) {+ $content = '[binary file]';+ }$this->content = $content;$this->is_directory = false;$this->save();diff --git a/resources/views/livewire/project/service/file-storage.blade.php b/resources/views/livewire/project/service/file-storage.blade.phpindex 550b43c205..e17835429e 100644--- a/resources/views/livewire/project/service/file-storage.blade.php+++ b/resources/views/livewire/project/service/file-storage.blade.php@@ -28,12 +28,15 @@confirmationLabel="Please confirm the execution of the actions by entering the Filepath below"shortConfirmationLabel="Filepath" step3ButtonText="Permanently Delete" />@else- <x-modal-confirmation title="Confirm File Conversion to Directory?" buttonTitle="Convert to directory"- submitAction="convertToDirectory" :actions="[- 'The selected file will be permanently deleted and an empty directory will be created in its place.',- ]" confirmationText="{{ $fs_path }}"- confirmationLabel="Please confirm the execution of the actions by entering the Filepath below"- shortConfirmationLabel="Filepath" :confirmWithPassword="false" step2ButtonText="Convert to directory" />+ @if (!$fileStorage->is_binary)+ <x-modal-confirmation title="Confirm File Conversion to Directory?"+ buttonTitle="Convert to directory" submitAction="convertToDirectory" :actions="[+ 'The selected file will be permanently deleted and an empty directory will be created in its place.',+ ]"+ confirmationText="{{ $fs_path }}"+ confirmationLabel="Please confirm the execution of the actions by entering the Filepath below"+ shortConfirmationLabel="Filepath" :confirmWithPassword="false" step2ButtonText="Convert to directory" />+ @endif<x-modal-confirmation title="Confirm File Deletion?" buttonTitle="Delete File" isErrorButtonsubmitAction="delete" :checkboxes="$fileDeletionCheckboxes" :actions="['The selected file will be permanently deleted from the container.']" confirmationText="{{ $fs_path }}"confirmationLabel="Please confirm the execution of the actions by entering the Filepath below"@@ -66,8 +69,8 @@<x-forms.textarealabel="{{ $fileStorage->is_based_on_git ? 'Content (refreshed after a successful deployment)' : 'Content' }}"rows="20" id="fileStorage.content"- readonly="{{ $fileStorage->is_based_on_git }}"></x-forms.textarea>- @if (!$fileStorage->is_based_on_git)+ readonly="{{ $fileStorage->is_based_on_git || $fileStorage->is_binary }}"></x-forms.textarea>+ @if (!$fileStorage->is_based_on_git && !$fileStorage->is_binary)<x-forms.button class="w-full" type="submit">Save</x-forms.button>@endif@endif