mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #153 from utopia-php/fix-export-inactive-deployments
This commit is contained in:
2 files changed
+43
-15
No files matched your search
@@ -1473,7 +1473,17 @@ class Appwrite extends Destination
|
||||
*/
|
||||
private function importDeployment(Deployment $deployment): Resource
|
||||
{
|
||||
$functionId = $deployment->getFunction()->getId();
|
||||
$function = $deployment->getFunction();
|
||||
|
||||
// Deployment API always creates a new deployment, so unlike other resources
|
||||
// there's no duplicate detection. Skip if the parent function wasn't imported successfully.
|
||||
if ($function->getStatus() !== Resource::STATUS_SUCCESS) {
|
||||
$deployment->setStatus(Resource::STATUS_SKIPPED, 'Parent function "' . $function->getId() . '" failed to import');
|
||||
|
||||
return $deployment;
|
||||
}
|
||||
|
||||
$functionId = $function->getId();
|
||||
|
||||
$response = null;
|
||||
|
||||
@@ -1508,7 +1518,7 @@ class Appwrite extends Destination
|
||||
[
|
||||
'functionId' => $functionId,
|
||||
'code' => new \CURLFile('data://application/gzip;base64,' . base64_encode($deployment->getData()), 'application/gzip', 'deployment.tar.gz'),
|
||||
'activate' => $deployment->getActivated(),
|
||||
'activate' => $deployment->getActivated() ? 'true' : 'false',
|
||||
'entrypoint' => $deployment->getEntrypoint(),
|
||||
]
|
||||
);
|
||||
@@ -1674,7 +1684,17 @@ class Appwrite extends Destination
|
||||
*/
|
||||
private function importSiteDeployment(SiteDeployment $deployment): Resource
|
||||
{
|
||||
$siteId = $deployment->getSite()->getId();
|
||||
$site = $deployment->getSite();
|
||||
|
||||
// Deployment API always creates a new deployment, so unlike other resources
|
||||
// there's no duplicate detection. Skip if the parent site wasn't imported successfully.
|
||||
if ($site->getStatus() !== Resource::STATUS_SUCCESS) {
|
||||
$deployment->setStatus(Resource::STATUS_SKIPPED, 'Parent site "' . $site->getId() . '" failed to import');
|
||||
|
||||
return $deployment;
|
||||
}
|
||||
|
||||
$siteId = $site->getId();
|
||||
|
||||
if ($deployment->getSize() <= Transfer::STORAGE_MAX_CHUNK_SIZE) {
|
||||
$response = $this->client->call(
|
||||
@@ -1686,7 +1706,7 @@ class Appwrite extends Destination
|
||||
[
|
||||
'siteId' => $siteId,
|
||||
'code' => new \CURLFile('data://application/gzip;base64,' . base64_encode($deployment->getData()), 'application/gzip', 'deployment.tar.gz'),
|
||||
'activate' => $deployment->getActivated(),
|
||||
'activate' => $deployment->getActivated() ? 'true' : 'false',
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1710,7 +1730,7 @@ class Appwrite extends Destination
|
||||
[
|
||||
'siteId' => $siteId,
|
||||
'code' => new \CURLFile('data://application/gzip;base64,' . base64_encode($deployment->getData()), 'application/gzip', 'deployment.tar.gz'),
|
||||
'activate' => $deployment->getActivated(),
|
||||
'activate' => $deployment->getActivated() ? 'true' : 'false',
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
@@ -1518,9 +1518,8 @@ class Appwrite extends Source
|
||||
}
|
||||
|
||||
try {
|
||||
if (\in_array(Resource::TYPE_DEPLOYMENT, $resources)) {
|
||||
$this->exportDeployments($batchSize, true);
|
||||
}
|
||||
$exportOnlyActive = !\in_array(Resource::TYPE_DEPLOYMENT, $resources);
|
||||
$this->exportDeployments($batchSize, $exportOnlyActive);
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_DEPLOYMENT,
|
||||
@@ -1549,9 +1548,8 @@ class Appwrite extends Source
|
||||
}
|
||||
|
||||
try {
|
||||
if (\in_array(Resource::TYPE_SITE_DEPLOYMENT, $resources)) {
|
||||
$this->exportSiteDeployments($batchSize, true);
|
||||
}
|
||||
$exportOnlyActive = !\in_array(Resource::TYPE_SITE_DEPLOYMENT, $resources);
|
||||
$this->exportSiteDeployments($batchSize, $exportOnlyActive);
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_SITE_DEPLOYMENT,
|
||||
@@ -1643,8 +1641,13 @@ class Appwrite extends Source
|
||||
/** @var Func $func */
|
||||
$lastDocument = null;
|
||||
|
||||
if ($exportOnlyActive && $func->getActiveDeployment()) {
|
||||
$deployment = $this->functions->getDeployment($func->getId(), $func->getActiveDeployment());
|
||||
if ($exportOnlyActive) {
|
||||
$activeDeploymentId = $func->getActiveDeployment();
|
||||
if (empty($activeDeploymentId)) {
|
||||
continue; // active-only mode: nothing to export for this function
|
||||
}
|
||||
|
||||
$deployment = $this->functions->getDeployment($func->getId(), $activeDeploymentId);
|
||||
|
||||
try {
|
||||
$this->exportDeploymentData($func, $deployment);
|
||||
@@ -1865,8 +1868,13 @@ class Appwrite extends Source
|
||||
/** @var Site $site */
|
||||
$lastDocument = null;
|
||||
|
||||
if ($exportOnlyActive && $site->getActiveDeployment()) {
|
||||
$deployment = $this->sites->getDeployment($site->getId(), $site->getActiveDeployment());
|
||||
if ($exportOnlyActive) {
|
||||
$activeDeploymentId = $site->getActiveDeployment();
|
||||
if (empty($activeDeploymentId)) {
|
||||
continue; // active-only mode: nothing to export for this site
|
||||
}
|
||||
|
||||
$deployment = $this->sites->getDeployment($site->getId(), $activeDeploymentId);
|
||||
|
||||
try {
|
||||
$this->exportSiteDeploymentData($site, $deployment);
|
||||
|
||||
Reference in new issue
Block a user