@@ -1473,7 +1473,17 @@ public function importFunctionResource(Resource $resource): Resource
14731473 */
14741474 private function importDeployment (Deployment $ deployment ): Resource
14751475 {
1476- $ functionId = $ deployment ->getFunction ()->getId ();
1476+ $ function = $ deployment ->getFunction ();
1477+
1478+ // Deployment API always creates a new deployment, so unlike other resources
1479+ // there's no duplicate detection. Skip if the parent function wasn't imported successfully.
1480+ if ($ function ->getStatus () !== Resource::STATUS_SUCCESS ) {
1481+ $ deployment ->setStatus (Resource::STATUS_SKIPPED , 'Parent function " ' . $ function ->getId () . '" failed to import ' );
1482+
1483+ return $ deployment ;
1484+ }
1485+
1486+ $ functionId = $ function ->getId ();
14771487
14781488 $ response = null ;
14791489
@@ -1508,7 +1518,7 @@ private function importDeployment(Deployment $deployment): Resource
15081518 [
15091519 'functionId ' => $ functionId ,
15101520 'code ' => new \CURLFile ('data://application/gzip;base64, ' . base64_encode ($ deployment ->getData ()), 'application/gzip ' , 'deployment.tar.gz ' ),
1511- 'activate ' => $ deployment ->getActivated (),
1521+ 'activate ' => $ deployment ->getActivated () ? ' true ' : ' false ' ,
15121522 'entrypoint ' => $ deployment ->getEntrypoint (),
15131523 ]
15141524 );
@@ -1674,7 +1684,17 @@ public function importSiteResource(Resource $resource): Resource
16741684 */
16751685 private function importSiteDeployment (SiteDeployment $ deployment ): Resource
16761686 {
1677- $ siteId = $ deployment ->getSite ()->getId ();
1687+ $ site = $ deployment ->getSite ();
1688+
1689+ // Deployment API always creates a new deployment, so unlike other resources
1690+ // there's no duplicate detection. Skip if the parent site wasn't imported successfully.
1691+ if ($ site ->getStatus () !== Resource::STATUS_SUCCESS ) {
1692+ $ deployment ->setStatus (Resource::STATUS_SKIPPED , 'Parent site " ' . $ site ->getId () . '" failed to import ' );
1693+
1694+ return $ deployment ;
1695+ }
1696+
1697+ $ siteId = $ site ->getId ();
16781698
16791699 if ($ deployment ->getSize () <= Transfer::STORAGE_MAX_CHUNK_SIZE ) {
16801700 $ response = $ this ->client ->call (
@@ -1686,7 +1706,7 @@ private function importSiteDeployment(SiteDeployment $deployment): Resource
16861706 [
16871707 'siteId ' => $ siteId ,
16881708 'code ' => new \CURLFile ('data://application/gzip;base64, ' . base64_encode ($ deployment ->getData ()), 'application/gzip ' , 'deployment.tar.gz ' ),
1689- 'activate ' => $ deployment ->getActivated (),
1709+ 'activate ' => $ deployment ->getActivated () ? ' true ' : ' false ' ,
16901710 ]
16911711 );
16921712
@@ -1710,7 +1730,7 @@ private function importSiteDeployment(SiteDeployment $deployment): Resource
17101730 [
17111731 'siteId ' => $ siteId ,
17121732 'code ' => new \CURLFile ('data://application/gzip;base64, ' . base64_encode ($ deployment ->getData ()), 'application/gzip ' , 'deployment.tar.gz ' ),
1713- 'activate ' => $ deployment ->getActivated (),
1733+ 'activate ' => $ deployment ->getActivated () ? ' true ' : ' false ' ,
17141734 ]
17151735 );
17161736
0 commit comments