fix: predefined content for files

This commit is contained in:
Andras Bacsai
2023-10-02 18:02:32 +02:00
parent 58e3bb2571
commit 9701c65297
5 changed files with 14 additions and 10 deletions

View File

@@ -33,9 +33,6 @@ class Show extends Component
$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);
}

View File

@@ -287,7 +287,10 @@ class Service extends BaseModel
$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 @@ class Service extends BaseModel
]
);
}
$savedService->getFilesFromServer();
$savedService->getFilesFromServer(isInit: true);
return $volume;
});
data_set($service, 'volumes', $serviceVolumes->toArray());

View File

@@ -36,8 +36,8 @@ class ServiceApplication extends BaseModel
);
}
public function getFilesFromServer()
public function getFilesFromServer(bool $isInit = false)
{
getFilesystemVolumesFromServer($this);
getFilesystemVolumesFromServer($this, $isInit);
}
}

View File

@@ -26,8 +26,8 @@ class ServiceDatabase extends BaseModel
{
return $this->morphMany(LocalFileVolume::class, 'resource');
}
public function getFilesFromServer()
public function getFilesFromServer(bool $isInit = false)
{
getFilesystemVolumesFromServer($this);
getFilesystemVolumesFromServer($this, $isInit);
}
}