Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor image synchronization in ClientTransfer class #753

Merged
merged 3 commits into from
Feb 7, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ In order to read more about upgrading and BC breaks have a look at the [UPGRADE
+ [#749](https://github.com/luyadev/luya-module-admin/pull/749) Added a new property, `luya\admin\Module::$apiUserTrackLastActivity`, which controls the update of the last activity timestamp for API users. By default, this feature is enabled to maintain backward compatibility. For larger systems, disabling this property can prevent unnecessary database writes.
+ [#751](https://github.com/luyadev/luya-module-admin/pull/751) Fixed parameter placeholders in translations (hu, nl, pl).
+ [#752](https://github.com/luyadev/luya-module-admin/pull/752) Updated links to new guide.
+ [#753](https://github.com/luyadev/luya-module-admin/pull/753) Enhanced error handling for scenarios where the proxy command attempts to synchronize a non-existent file.

## 5.0.0 (30. November 2023)

Expand Down
40 changes: 22 additions & 18 deletions src/proxy/ClientTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,30 @@ protected function startImages()
$imageCount = 0;
// sync images
foreach ((new \luya\admin\image\Query())->all() as $image) {
/** @var Item $image */
if (!$image->fileExists) {
$curl = new Curl();
$curl->setOpt(CURLOPT_RETURNTRANSFER, true);
$curl->get($this->build->imageProviderUrl, [
'buildToken' => $this->build->buildToken,
'machine' => $this->build->machineIdentifier,
'imageId' => $image->id,
]);

if (!$curl->error) {
if ($this->storageUpload($image->systemFileName, $curl->response)) {
$imageCount++;
$this->build->command->outputInfo('[+] Image ' . $image->source.' downloaded.');
try {
/** @var Item $image */
if (!$image->fileExists) {
$curl = new Curl();
$curl->setOpt(CURLOPT_RETURNTRANSFER, true);
$curl->get($this->build->imageProviderUrl, [
'buildToken' => $this->build->buildToken,
'machine' => $this->build->machineIdentifier,
'imageId' => $image->id,
]);

if (!$curl->error) {
if ($this->storageUpload($image->systemFileName, $curl->response)) {
$imageCount++;
$this->build->command->outputInfo('[+] Image ' . $image->source.' downloaded.');
}
}
}

$curl->close();
unset($curl);
gc_collect_cycles();
$curl->close();
unset($curl);
gc_collect_cycles();
}
} catch (Exception $e) {
$this->build->command->outputError('[!] Unable to download image due to error: ' . $e->getMessage());
}
}

Expand Down
Loading