simplify and harden the configuration file writeouts, didn't knew

file_put_contents was around for so long already...
This commit is contained in:
Thomas Keller 2010-08-30 09:00:20 +02:00
parent b648e6f7a7
commit adae73080c

View File

@ -157,10 +157,11 @@ end
END; END;
$rcfile = $projectpath.'/monotonerc'; $rcfile = $projectpath.'/monotonerc';
// FIXME: sanity if (!file_put_contents($rcfile, $monotonerc, LOCK_EX)) {
$fp = fopen($rcfile, 'w'); throw new IDF_Scm_Exception(sprintf(
fwrite($fp, $monotonerc); __('Could not write mtn configuration file "%s"'), $rcfile)
fclose($fp); ));
}
// //
// step 4) read in and append the usher config with the new server // step 4) read in and append the usher config with the new server
@ -205,10 +206,13 @@ END;
$parsed_config[] = $new_server; $parsed_config[] = $new_server;
$usher_rc = IDF_Scm_Monotone_BasicIO::compile($parsed_config); $usher_rc = IDF_Scm_Monotone_BasicIO::compile($parsed_config);
// FIXME: more sanity - what happens on failing writes? // FIXME: more sanity - what happens on failing writes? we do not
$fp = fopen($usher_config, 'w'); // have a backup copy of usher.conf around...
fwrite($fp, $usher_rc); if (!file_put_contents($usher_config, $usher_rc, LOCK_EX)) {
fclose($fp); throw new IDF_Scm_Exception(sprintf(
__('Could not write usher configuration file "%s"'), $usher_config)
));
}
// //
// step 5) reload usher to pick up the new configuration // step 5) reload usher to pick up the new configuration