From 6dd86eec30b5b1d63017332f56350bce8b8e7de0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 14 Feb 2024 10:13:49 +0100 Subject: [PATCH] Fix directory creation issue in LocalFileVolume.php and parseDockerComposeFile() --- app/Models/LocalFileVolume.php | 2 +- bootstrap/helpers/shared.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.php index f426e40a0..caeab8915 100644 --- a/app/Models/LocalFileVolume.php +++ b/app/Models/LocalFileVolume.php @@ -39,7 +39,7 @@ class LocalFileVolume extends BaseModel if (!$fileVolume->is_directory && $isDir == 'NOK') { $content = base64_encode($content); $commands->push("echo '$content' | base64 -d > $path"); - } else if ($isDir == 'NOK' && $fileVolume->is_directory) { + } else if ($isDir == 'NOK' && $fileVolume->is_directory) { $commands->push("mkdir -p $path > /dev/null 2>&1 || true"); } ray($commands->toArray()); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 7ffc6a72c..10d8f313b 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -782,14 +782,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $source = data_get_str($volume, 'source'); $target = data_get_str($volume, 'target'); $content = data_get($volume, 'content'); - $isDirectory = (bool) data_get($volume, 'isDirectory', false); + $isDirectory = (bool) data_get($volume, 'isDirectory', false) || (bool) data_get($volume, 'is_directory', false); $foundConfig = $savedService->fileStorages()->whereMountPath($target)->first(); if ($foundConfig) { $contentNotNull = data_get($foundConfig, 'content'); if ($contentNotNull) { $content = $contentNotNull; } - $isDirectory = (bool) data_get($foundConfig, 'is_directory'); + $isDirectory = (bool) data_get($volume, 'isDirectory', false) || (bool) data_get($volume, 'is_directory', false); } } if ($type->value() === 'bind') { @@ -1054,6 +1054,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal data_set($service, 'container_name', $containerName); data_forget($service, 'volumes.*.content'); data_forget($service, 'volumes.*.isDirectory'); + data_forget($service, 'volumes.*.is_directory'); + // Remove unnecessary variables from service.environment // $withoutServiceEnvs = collect([]); // collect(data_get($service, 'environment'))->each(function ($value, $key) use ($withoutServiceEnvs) {