fix: create file storage even if content is empty

This commit is contained in:
Andras Bacsai 2024-07-22 09:18:15 +02:00
parent 7459ab22d1
commit 8ffbccf7db

View File

@ -87,19 +87,21 @@ public function saveStorageOnServer()
$fileVolume->save(); $fileVolume->save();
throw new \Exception('The following file is a directory on the server, but you are trying to mark it as a file. <br><br>Please delete the directory on the server or mark it as directory.'); throw new \Exception('The following file is a directory on the server, but you are trying to mark it as a file. <br><br>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) { if ($content) {
$content = base64_encode($content); $content = base64_encode($content);
$chmod = $fileVolume->chmod;
$chown = $fileVolume->chown;
$commands->push("echo '$content' | base64 -d | tee $path > /dev/null"); $commands->push("echo '$content' | base64 -d | tee $path > /dev/null");
$commands->push("chmod +x $path"); } else {
if ($chown) { $commands->push("touch $path");
$commands->push("chown $chown $path"); }
} $commands->push("chmod +x $path");
if ($chmod) { if ($chown) {
$commands->push("chmod $chmod $path"); $commands->push("chown $chown $path");
} }
if ($chmod) {
$commands->push("chmod $chmod $path");
} }
} elseif ($isDir == 'NOK' && $fileVolume->is_directory) { } elseif ($isDir == 'NOK' && $fileVolume->is_directory) {
$commands->push("mkdir -p $path > /dev/null 2>&1 || true"); $commands->push("mkdir -p $path > /dev/null 2>&1 || true");