From 58e3bb2571b91f20c52cbe4ea2ed8b0f4cfde6bd Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 2 Oct 2023 18:01:24 +0200 Subject: [PATCH 1/2] version++ --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index 0cc516460..5bd48364a 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.58', + 'release' => '4.0.0-beta.59', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 87313c7d1..75c583caf 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Mon, 2 Oct 2023 18:02:32 +0200 Subject: [PATCH 2/2] fix: predefined content for files --- app/Http/Livewire/Project/Service/Show.php | 3 --- app/Models/Service.php | 7 +++++-- app/Models/ServiceApplication.php | 4 ++-- app/Models/ServiceDatabase.php | 4 ++-- bootstrap/helpers/services.php | 6 +++++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Http/Livewire/Project/Service/Show.php b/app/Http/Livewire/Project/Service/Show.php index ebeb24ebc..958fd595a 100644 --- a/app/Http/Livewire/Project/Service/Show.php +++ b/app/Http/Livewire/Project/Service/Show.php @@ -33,9 +33,6 @@ public function mount() $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first(); $this->serviceDatabase->getFilesFromServer(); } - if (is_null($service)) { - throw new \Exception("Service not found."); - } } catch(\Throwable $e) { return handleError($e, $this); } diff --git a/app/Models/Service.php b/app/Models/Service.php index a430dc2dd..c23ff075a 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -287,7 +287,10 @@ public function parse(bool $isNew = false): Collection $isDirectory = (bool) data_get($volume, 'isDirectory', false); $foundConfig = $savedService->fileStorages()->whereMountPath($target)->first(); if ($foundConfig) { - $content = data_get($foundConfig, 'content'); + $contentNotNull = data_get($foundConfig, 'content'); + if ($contentNotNull) { + $content = $contentNotNull; + } $isDirectory = (bool) data_get($foundConfig, 'is_directory'); } } @@ -343,7 +346,7 @@ public function parse(bool $isNew = false): Collection ] ); } - $savedService->getFilesFromServer(); + $savedService->getFilesFromServer(isInit: true); return $volume; }); data_set($service, 'volumes', $serviceVolumes->toArray()); diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php index 58569b6bd..284453c42 100644 --- a/app/Models/ServiceApplication.php +++ b/app/Models/ServiceApplication.php @@ -36,8 +36,8 @@ public function fqdns(): Attribute ); } - public function getFilesFromServer() + public function getFilesFromServer(bool $isInit = false) { - getFilesystemVolumesFromServer($this); + getFilesystemVolumesFromServer($this, $isInit); } } diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php index a94bca40a..057db8e67 100644 --- a/app/Models/ServiceDatabase.php +++ b/app/Models/ServiceDatabase.php @@ -26,8 +26,8 @@ public function fileStorages() { return $this->morphMany(LocalFileVolume::class, 'resource'); } - public function getFilesFromServer() + public function getFilesFromServer(bool $isInit = false) { - getFilesystemVolumesFromServer($this); + getFilesystemVolumesFromServer($this, $isInit); } } diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php index 7977d4d26..306ca172f 100644 --- a/bootstrap/helpers/services.php +++ b/bootstrap/helpers/services.php @@ -64,7 +64,7 @@ function serviceStatus(Service $service) } return 'exited'; } -function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneService) +function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneService, bool $isInit = false) { // TODO: make this async try { @@ -87,6 +87,10 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneS } $isFile = instant_remote_process(["test -f $fileLocation && echo OK || echo NOK"], $server); $isDir = instant_remote_process(["test -d $fileLocation && echo OK || echo NOK"], $server); + if ($isFile === 'NOK' &&!$fileVolume->is_directory && $isInit) { + $fileVolume->saveStorageOnServer($oneService); + continue; + } if ($isFile == 'OK' && !$fileVolume->is_directory) { $filesystemContent = instant_remote_process(["cat $fileLocation"], $server); if (base64_encode($filesystemContent) != base64_encode($content)) {