Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions app/Jobs/UpdateSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Site;
use App\RemoteSite\Connection;
use App\RemoteSite\Responses\PrepareUpdate;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
Expand Down Expand Up @@ -96,6 +97,9 @@ public function handle(): void

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

// Perform additional preparation calls
$this->performExtraPreparations($prepareResult);

// Perform the actual extraction
try {
$this->performExtraction($prepareResult);
Expand Down Expand Up @@ -131,6 +135,29 @@ public function handle(): void
CheckSiteHealth::dispatch($this->site);
}

protected function performExtraPreparations(PrepareUpdate $prepareResult): void
{
if (!count($prepareResult->preparationUrls)) {
return;
}

/** @var Client $httpClient */
$httpClient = App::make(Client::class);

// Call each preparation URL
foreach ($prepareResult->preparationUrls as $url) {
$httpClient->get(
$url,
[
'timeout' => 30.0,
'allow_redirects' => [
'max' => 100
]
]
);
}
}

protected function performExtraction(PrepareUpdate $prepareResult): void
{
/** Create a separate connection with the extraction password **/
Expand Down
3 changes: 2 additions & 1 deletion app/RemoteSite/Responses/PrepareUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class PrepareUpdate extends BaseDTO implements ResponseInterface
{
public function __construct(
public string $password,
public int $filesize
public int $filesize,
public array $preparationUrls = []
) {
}
}