From 8ffbccf7db072896cefacd7527dbeb1733d44536 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 22 Jul 2024 09:18:15 +0200 Subject: [PATCH] fix: create file storage even if content is empty --- app/Models/LocalFileVolume.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.php index 0b9491da6..decfb1a8d 100644 --- a/app/Models/LocalFileVolume.php +++ b/app/Models/LocalFileVolume.php @@ -87,19 +87,21 @@ public function saveStorageOnServer() $fileVolume->save(); throw new \Exception('The following file is a directory on the server, but you are trying to mark it as a file.

Please delete the directory on the server or mark it as directory.'); } - if (! $fileVolume->is_directory && $isDir == 'NOK') { + if ($isDir == 'NOK' && ! $fileVolume->is_directory) { + $chmod = data_get($fileVolume, 'chmod'); + $chown = data_get($fileVolume, 'chown'); if ($content) { $content = base64_encode($content); - $chmod = $fileVolume->chmod; - $chown = $fileVolume->chown; $commands->push("echo '$content' | base64 -d | tee $path > /dev/null"); - $commands->push("chmod +x $path"); - if ($chown) { - $commands->push("chown $chown $path"); - } - if ($chmod) { - $commands->push("chmod $chmod $path"); - } + } else { + $commands->push("touch $path"); + } + $commands->push("chmod +x $path"); + if ($chown) { + $commands->push("chown $chown $path"); + } + if ($chmod) { + $commands->push("chmod $chmod $path"); } } elseif ($isDir == 'NOK' && $fileVolume->is_directory) { $commands->push("mkdir -p $path > /dev/null 2>&1 || true");