diff --git a/package_manager/src/PathExcluder/SiteConfigurationExcluder.php b/package_manager/src/PathExcluder/SiteConfigurationExcluder.php index c94632257caa58688a410f3330b9cf0714349795..aff1369e99ad5773b2e62ec363a7b39004352e9a 100644 --- a/package_manager/src/PathExcluder/SiteConfigurationExcluder.php +++ b/package_manager/src/PathExcluder/SiteConfigurationExcluder.php @@ -74,6 +74,10 @@ class SiteConfigurationExcluder implements EventSubscriberInterface { */ public function makeDefaultSiteDirectoryWritable(PostCreateEvent $event): void { $dir = $this->getDefaultSiteDirectoryPath($event->stage->getStageDirectory()); + // If the directory doesn't even exist, there's nothing to do here. + if (!is_dir($dir)) { + return; + } if (!$this->fileSystem->chmod($dir, 0777)) { throw new FileException("Could not change permissions on '$dir'."); } @@ -90,8 +94,12 @@ class SiteConfigurationExcluder implements EventSubscriberInterface { * cannot be determined, or cannot be changed on the staged `sites/default`. */ public function syncDefaultSiteDirectoryPermissions(PreApplyEvent $event): void { - $live_dir = $this->getDefaultSiteDirectoryPath($this->pathLocator->getProjectRoot()); $staged_dir = $this->getDefaultSiteDirectoryPath($event->stage->getStageDirectory()); + // If the directory doesn't even exist, there's nothing to do here. + if (!is_dir($staged_dir)) { + return; + } + $live_dir = $this->getDefaultSiteDirectoryPath($this->pathLocator->getProjectRoot()); // This is borrowed from \Symfony\Component\Filesystem\Filesystem::copy(), // to ensure the correct permissions are preserved (chmod() requires