From 1c159d096aee208c3dbbd47ae5f64181a1a8d9eb Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Mon, 1 Apr 2024 12:40:14 -0700 Subject: [PATCH] CLI-1282: [remote:aliases:download] warning on read-only directory --- src/Command/Remote/AliasesDownloadCommand.php | 8 +++++++- src/EventListener/ExceptionListener.php | 2 ++ tests/phpunit/src/Misc/ExceptionListenerTest.php | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Command/Remote/AliasesDownloadCommand.php b/src/Command/Remote/AliasesDownloadCommand.php index 4f9ff0cab..7579e8895 100644 --- a/src/Command/Remote/AliasesDownloadCommand.php +++ b/src/Command/Remote/AliasesDownloadCommand.php @@ -130,7 +130,13 @@ protected function downloadDrush9Aliases(InputInterface $input, string $aliasVer $drushFiles[] = $baseDir . '/' . $file->getFileName(); } } - $archive->extractTo($drushAliasesDir, $drushFiles, TRUE); + try { + // Throws warnings on permissions errors. + @$archive->extractTo($drushAliasesDir, $drushFiles, TRUE); + } + catch (\Exception) { + throw new AcquiaCliException('Could not extract aliases to {destination}', ['destination' => $drushAliasesDir]); + } } protected function downloadDrush8Aliases(string $aliasVersion, string $drushArchiveTempFilepath, string $drushAliasesDir): void { diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index 42ca280a4..a76bf61ae 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -67,6 +67,8 @@ public function onConsoleError(ConsoleErrorEvent $event): void { case 'This machine is not yet authenticated with Site Factory.': $this->helpMessages[] = 'Run `acli auth:acsf-login` to re-authenticate with Site Factory.'; break; + case 'Could not extract aliases to {destination}': + $this->helpMessages[] = 'Check that you have write access to the directory'; } } diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index 4b9bdce42..4bb0accbb 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -90,6 +90,10 @@ public function providerTestHelp(): array { new AcquiaCliException('This machine is not yet authenticated with Site Factory.'), 'Run `acli auth:acsf-login` to re-authenticate with Site Factory.', ], + [ + new AcquiaCliException('Could not extract aliases to {destination}'), + 'Check that you have write access to the directory', + ], [ new ApiErrorException((object) ['error' => '', 'message' => "There are no available Cloud IDEs for this application.\n"]), 'Delete an existing IDE via acli ide:delete or contact your Account Manager or Acquia Sales to purchase additional IDEs.',