Don't require Wings API call to pass in order to update server details
This commit is contained in:
		
							parent
							
								
									7330a747b7
								
							
						
					
					
						commit
						d8d1eacb42
					
				| @ -33,6 +33,8 @@ class BuildModificationService | |||||||
|      * BuildModificationService constructor. |      * BuildModificationService constructor. | ||||||
|      * |      * | ||||||
|      * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $structureService |      * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $structureService | ||||||
|  |      * @param \Illuminate\Database\ConnectionInterface $connection | ||||||
|  |      * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository | ||||||
|      */ |      */ | ||||||
|     public function __construct( |     public function __construct( | ||||||
|         ServerConfigurationStructureService $structureService, |         ServerConfigurationStructureService $structureService, | ||||||
| @ -56,6 +58,8 @@ class BuildModificationService | |||||||
|     { |     { | ||||||
|         $this->connection->beginTransaction(); |         $this->connection->beginTransaction(); | ||||||
| 
 | 
 | ||||||
|  |         /** @var \Pterodactyl\Models\Server $server */ | ||||||
|  |         $server = $this->connection->transaction(function() use ($server, $data) { | ||||||
|             $this->processAllocations($server, $data); |             $this->processAllocations($server, $data); | ||||||
| 
 | 
 | ||||||
|             if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) { |             if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) { | ||||||
| @ -76,14 +80,15 @@ class BuildModificationService | |||||||
|                 'backup_limit' => Arr::get($data, 'backup_limit', 0) ?? 0, |                 'backup_limit' => Arr::get($data, 'backup_limit', 0) ?? 0, | ||||||
|             ]))->saveOrFail(); |             ]))->saveOrFail(); | ||||||
| 
 | 
 | ||||||
|         $server = $server->fresh(); |             return $server->refresh(); | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         $updateData = $this->structureService->handle($server); |         $updateData = $this->structureService->handle($server); | ||||||
| 
 | 
 | ||||||
|         // Because Wings always fetches an updated configuration from the Panel when booting
 |         // Because Wings always fetches an updated configuration from the Panel when booting
 | ||||||
|         // a server this type of exception can be safely "ignored" and just written to the logs.
 |         // a server this type of exception can be safely "ignored" and just written to the logs.
 | ||||||
|         // Ideally this request succeedes so we can apply resource modifications on the fly
 |         // Ideally this request succeedes so we can apply resource modifications on the fly, but
 | ||||||
|         // but if it fails it isn't the end of the world.
 |         // if it fails we can just continue on as normal.
 | ||||||
|         if (!empty($updateData['build'])) { |         if (!empty($updateData['build'])) { | ||||||
|             try { |             try { | ||||||
|                 $this->daemonServerRepository->setServer($server)->update([ |                 $this->daemonServerRepository->setServer($server)->update([ | ||||||
| @ -94,8 +99,6 @@ class BuildModificationService | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $this->connection->commit(); |  | ||||||
| 
 |  | ||||||
|         return $server; |         return $server; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dane Everitt
						Dane Everitt