1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-22 21:40:54 +01:00

Make sure the local arc config directory exists on ArcanistWorkingCopyIdentity::writeLocalArcConfig

See: <https://github.com/facebook/arcanist/pull/126>

Reviewed by: epriestley
This commit is contained in:
Joshua Spence 2013-12-11 08:29:19 +11:00 committed by epriestley
parent e0b4eef9de
commit cd0ee5492a
2 changed files with 11 additions and 20 deletions

View file

@ -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!"));
}
/**

View file

@ -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);
}
}