mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: skip deployment import when parent resource already exists in destination
When a function or site already exists in the destination, the API returns 409 and the parent resource is marked as error. Previously, deployments for that parent would still be imported, creating duplicates. Now importDeployment and importSiteDeployment check the parent status and throw an error if it failed.
This commit is contained in:
1 parent
336358d7f3
commit
b827043cb7
1 file changed
+24
-2
@@ -1473,7 +1473,18 @@ class Appwrite extends Destination
|
||||
*/
|
||||
private function importDeployment(Deployment $deployment): Resource
|
||||
{
|
||||
$functionId = $deployment->getFunction()->getId();
|
||||
$function = $deployment->getFunction();
|
||||
|
||||
if ($function->getStatus() === Resource::STATUS_ERROR) {
|
||||
throw new Exception(
|
||||
resourceName: $deployment->getName(),
|
||||
resourceGroup: $deployment->getGroup(),
|
||||
resourceId: $deployment->getId(),
|
||||
message: 'Function "' . $function->getId() . '" already exists in destination',
|
||||
);
|
||||
}
|
||||
|
||||
$functionId = $function->getId();
|
||||
|
||||
$response = null;
|
||||
|
||||
@@ -1674,7 +1685,18 @@ class Appwrite extends Destination
|
||||
*/
|
||||
private function importSiteDeployment(SiteDeployment $deployment): Resource
|
||||
{
|
||||
$siteId = $deployment->getSite()->getId();
|
||||
$site = $deployment->getSite();
|
||||
|
||||
if ($site->getStatus() === Resource::STATUS_ERROR) {
|
||||
throw new Exception(
|
||||
resourceName: $deployment->getName(),
|
||||
resourceGroup: $deployment->getGroup(),
|
||||
resourceId: $deployment->getId(),
|
||||
message: 'Site "' . $site->getId() . '" already exists in destination',
|
||||
);
|
||||
}
|
||||
|
||||
$siteId = $site->getId();
|
||||
|
||||
if ($deployment->getSize() <= Transfer::STORAGE_MAX_CHUNK_SIZE) {
|
||||
$response = $this->client->call(
|
||||
|
||||
Reference in new issue
Block a user