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:
Prem Palanisamy authored and premtsd-code committed 2026-03-02 09:57:11 +00:00
1 parent 336358d7f3
commit b827043cb7
1 file changed
+24 -2
+24 -2
View File
@@ -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(