Skip to content

Commit da26853

Browse files
committed
Call prepare urls provided by site
1 parent 720c2a0 commit da26853

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

app/Jobs/UpdateSite.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Models\Site;
99
use App\RemoteSite\Connection;
1010
use App\RemoteSite\Responses\PrepareUpdate;
11+
use GuzzleHttp\Client;
1112
use GuzzleHttp\Exception\RequestException;
1213
use Illuminate\Contracts\Queue\ShouldQueue;
1314
use Illuminate\Foundation\Queue\Queueable;
@@ -96,6 +97,9 @@ public function handle(): void
9697

9798
$prepareResult = $connection->prepareUpdate(["targetVersion" => $this->targetVersion]);
9899

100+
// Perform additional preparation calls
101+
$this->performExtraPreparations($prepareResult);
102+
99103
// Perform the actual extraction
100104
try {
101105
$this->performExtraction($prepareResult);
@@ -131,6 +135,29 @@ public function handle(): void
131135
CheckSiteHealth::dispatch($this->site);
132136
}
133137

138+
protected function performExtraPreparations(PrepareUpdate $prepareResult): void
139+
{
140+
if (!count($prepareResult->preparationUrls)) {
141+
return;
142+
}
143+
144+
/** @var Client $httpClient */
145+
$httpClient = App::make(Client::class);
146+
147+
// Call each preparation URL
148+
foreach ($prepareResult->preparationUrls as $url) {
149+
$httpClient->get(
150+
$url,
151+
[
152+
'timeout' => 30.0,
153+
'allow_redirects' => [
154+
'max' => 100
155+
]
156+
]
157+
);
158+
}
159+
}
160+
134161
protected function performExtraction(PrepareUpdate $prepareResult): void
135162
{
136163
/** Create a separate connection with the extraction password **/

app/RemoteSite/Responses/PrepareUpdate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class PrepareUpdate extends BaseDTO implements ResponseInterface
88
{
99
public function __construct(
1010
public string $password,
11-
public int $filesize
11+
public int $filesize,
12+
public array $preparationUrls = []
1213
) {
1314
}
1415
}

0 commit comments

Comments
 (0)