This commit is contained in:
Andras Bacsai 2023-10-03 12:14:58 +02:00
parent 194675c838
commit 5255311a2e

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Spatie\Url\Url;
class Service extends BaseModel class Service extends BaseModel
{ {
@ -259,7 +260,7 @@ class Service extends BaseModel
$networks = $serviceNetworks->toArray(); $networks = $serviceNetworks->toArray();
foreach ($definedNetwork as $key => $network) { foreach ($definedNetwork as $key => $network) {
$networks = array_merge($networks, [ $networks = array_merge($networks, [
$network $network => null
]); ]);
} }
data_set($service, 'networks', $networks); data_set($service, 'networks', $networks);
@ -288,10 +289,7 @@ class Service extends BaseModel
$isDirectory = (bool) data_get($volume, 'isDirectory', false); $isDirectory = (bool) data_get($volume, 'isDirectory', false);
$foundConfig = $savedService->fileStorages()->whereMountPath($target)->first(); $foundConfig = $savedService->fileStorages()->whereMountPath($target)->first();
if ($foundConfig) { if ($foundConfig) {
$contentNotNull = data_get($foundConfig, 'content'); $content = data_get($foundConfig, 'content');
if ($contentNotNull) {
$content = $contentNotNull;
}
$isDirectory = (bool) data_get($foundConfig, 'is_directory'); $isDirectory = (bool) data_get($foundConfig, 'is_directory');
} }
} }
@ -319,7 +317,11 @@ class Service extends BaseModel
); );
} else if ($type->value() === 'volume') { } else if ($type->value() === 'volume') {
$slug = Str::slug($source, '-'); $slug = Str::slug($source, '-');
$name = "{$savedService->service->uuid}_{$slug}"; if ($isNew) {
$name = "{$savedService->service->uuid}-{$slug}";
} else {
$name = "{$savedService->service->uuid}_{$slug}";
}
if (is_string($volume)) { if (is_string($volume)) {
$source = Str::of($volume)->before(':'); $source = Str::of($volume)->before(':');
$target = Str::of($volume)->after(':')->beforeLast(':'); $target = Str::of($volume)->after(':')->beforeLast(':');
@ -343,7 +345,7 @@ class Service extends BaseModel
] ]
); );
} }
$savedService->getFilesFromServer(isInit: true); $savedService->getFilesFromServer();
return $volume; return $volume;
}); });
data_set($service, 'volumes', $serviceVolumes->toArray()); data_set($service, 'volumes', $serviceVolumes->toArray());