mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +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:
parent
e0b4eef9de
commit
cd0ee5492a
2 changed files with 11 additions and 20 deletions
|
@ -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!"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue