| @@ -33,9 +33,6 @@ class Show extends Component | |||||||
|                 $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first(); |                 $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first(); | ||||||
|                 $this->serviceDatabase->getFilesFromServer(); |                 $this->serviceDatabase->getFilesFromServer(); | ||||||
|             } |             } | ||||||
|             if (is_null($service)) { |  | ||||||
|                 throw new \Exception("Service not found."); |  | ||||||
|             } |  | ||||||
|         } catch(\Throwable $e) { |         } catch(\Throwable $e) { | ||||||
|             return handleError($e, $this); |             return handleError($e, $this); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -287,7 +287,10 @@ 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) { | ||||||
|                                 $content = data_get($foundConfig, 'content'); |                                 $contentNotNull = data_get($foundConfig, 'content'); | ||||||
|  |                                 if ($contentNotNull) { | ||||||
|  |                                     $content = $contentNotNull; | ||||||
|  |                                 } | ||||||
|                                 $isDirectory = (bool) data_get($foundConfig, 'is_directory'); |                                 $isDirectory = (bool) data_get($foundConfig, 'is_directory'); | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
| @@ -343,7 +346,7 @@ class Service extends BaseModel | |||||||
|                                 ] |                                 ] | ||||||
|                             ); |                             ); | ||||||
|                         } |                         } | ||||||
|                         $savedService->getFilesFromServer(); |                         $savedService->getFilesFromServer(isInit: true); | ||||||
|                         return $volume; |                         return $volume; | ||||||
|                     }); |                     }); | ||||||
|                     data_set($service, 'volumes', $serviceVolumes->toArray()); |                     data_set($service, 'volumes', $serviceVolumes->toArray()); | ||||||
|   | |||||||
| @@ -36,8 +36,8 @@ class ServiceApplication extends BaseModel | |||||||
| 
 | 
 | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|     public function getFilesFromServer() |     public function getFilesFromServer(bool $isInit = false) | ||||||
|     { |     { | ||||||
|         getFilesystemVolumesFromServer($this); |         getFilesystemVolumesFromServer($this, $isInit); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,8 +26,8 @@ class ServiceDatabase extends BaseModel | |||||||
|     { |     { | ||||||
|         return $this->morphMany(LocalFileVolume::class, 'resource'); |         return $this->morphMany(LocalFileVolume::class, 'resource'); | ||||||
|     } |     } | ||||||
|     public function getFilesFromServer() |     public function getFilesFromServer(bool $isInit = false) | ||||||
|     { |     { | ||||||
|         getFilesystemVolumesFromServer($this); |         getFilesystemVolumesFromServer($this, $isInit); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -64,7 +64,7 @@ function serviceStatus(Service $service) | |||||||
|     } |     } | ||||||
|     return 'exited'; |     return 'exited'; | ||||||
| } | } | ||||||
| function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneService) | function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneService, bool $isInit = false) | ||||||
| { | { | ||||||
|     // TODO: make this async
 |     // TODO: make this async
 | ||||||
|     try { |     try { | ||||||
| @@ -87,6 +87,10 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneS | |||||||
|             } |             } | ||||||
|             $isFile = instant_remote_process(["test -f $fileLocation && echo OK || echo NOK"], $server); |             $isFile = instant_remote_process(["test -f $fileLocation && echo OK || echo NOK"], $server); | ||||||
|             $isDir = instant_remote_process(["test -d $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) { |             if ($isFile == 'OK' && !$fileVolume->is_directory) { | ||||||
|                 $filesystemContent = instant_remote_process(["cat $fileLocation"], $server); |                 $filesystemContent = instant_remote_process(["cat $fileLocation"], $server); | ||||||
|                 if (base64_encode($filesystemContent) != base64_encode($content)) { |                 if (base64_encode($filesystemContent) != base64_encode($content)) { | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ return [ | |||||||
| 
 | 
 | ||||||
|     // The release version of your application
 |     // The release version of your application
 | ||||||
|     // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 |     // 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
 |     // When left empty or `null` the Laravel environment will be used
 | ||||||
|     'environment' => config('app.env'), |     'environment' => config('app.env'), | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -1,3 +1,3 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
| return '4.0.0-beta.58'; | return '4.0.0-beta.59'; | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|             "version": "3.12.36" |             "version": "3.12.36" | ||||||
|         }, |         }, | ||||||
|         "v4": { |         "v4": { | ||||||
|             "version": "4.0.0-beta.58" |             "version": "4.0.0-beta.59" | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai