From cd0ee5492a7702c76fc49925cbb94bc46ca002d4 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Wed, 11 Dec 2013 08:29:19 +1100 Subject: [PATCH] Make sure the local arc config directory exists on `ArcanistWorkingCopyIdentity::writeLocalArcConfig` See: Reviewed by: epriestley --- .../ArcanistConfigurationManager.php | 2 +- .../ArcanistWorkingCopyIdentity.php | 29 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php index 79c5a756..bc22240c 100644 --- a/src/configuration/ArcanistConfigurationManager.php +++ b/src/configuration/ArcanistConfigurationManager.php @@ -145,7 +145,7 @@ final class ArcanistConfigurationManager { return $this->workingCopy->writeLocalArcConfig($config); } - return false; + throw new Exception(pht("No working copy to write config to!")); } /** diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php index 7c617153..e94dec93 100644 --- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php +++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php @@ -312,30 +312,21 @@ final class ArcanistWorkingCopyIdentity { } public function writeLocalArcConfig(array $config) { - $dir = $this->localMetaDir; - if (!strlen($dir)) { - return false; - } - - if (!Filesystem::pathExists($dir)) { - try { - Filesystem::createDirectory($dir); - } catch (Exception $ex) { - return false; - } - } - $json_encoder = new PhutilJSON(); $json = $json_encoder->encodeFormatted($config); - $config_file = Filesystem::resolvePath('arc/config', $dir); - try { - Filesystem::writeFile($config_file, $json); - } catch (FilesystemException $ex) { - return false; + $dir = $this->localMetaDir; + if (!strlen($dir)) { + throw new Exception(pht('No working copy to write config into!')); } - return true; + $local_dir = $dir.DIRECTORY_SEPARATOR.'arc'; + if (!Filesystem::pathExists($local_dir)) { + Filesystem::createDirectory($local_dir, 0755); + } + + $config_file = $local_dir.DIRECTORY_SEPARATOR.'config'; + Filesystem::writeFile($config_file, $json); } }