aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-14 13:57:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-14 17:59:13 +0100
commit790984559ffb668dc6b87799a193e9492ef14d3c (patch)
tree4b6e2cce8fed27fd8a29835be8c6a165899fecef
parent20e834878b400401c622c3f835af7200e830e7e2 (diff)
downloadpaludis-790984559ffb668dc6b87799a193e9492ef14d3c.tar.gz
paludis-790984559ffb668dc6b87799a193e9492ef14d3c.tar.xz
Nuke the config file on failure
-rw-r--r--paludis/repositories/repository/repository_repository.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/paludis/repositories/repository/repository_repository.cc b/paludis/repositories/repository/repository_repository.cc
index 8217da2..d421291 100644
--- a/paludis/repositories/repository/repository_repository.cc
+++ b/paludis/repositories/repository/repository_repository.cc
@@ -455,14 +455,25 @@ RepositoryRepository::merge(const MergeParams & m)
if (config_filename_file.exists())
throw ConfigurationError("config_filename '" + stringify(config_filename_file) + "' already exists");
- m.output_manager()->stdout_stream() << "Creating " << config_filename_file << "..." << std::endl;
+ try
+ {
+ m.output_manager()->stdout_stream() << "Creating " << config_filename_file << "..." << std::endl;
- SafeIFStream config_template_input(config_template_file);
- std::string data((std::istreambuf_iterator<char>(config_template_input)), std::istreambuf_iterator<char>());
- data = replace_vars(data, repo_sync, repo_format, repo_name);
+ {
+ SafeIFStream config_template_input(config_template_file);
+ std::string data((std::istreambuf_iterator<char>(config_template_input)), std::istreambuf_iterator<char>());
+ data = replace_vars(data, repo_sync, repo_format, repo_name);
- SafeOFStream config_filename_output(config_filename_file);
- config_filename_output << data;
+ SafeOFStream config_filename_output(config_filename_file);
+ config_filename_output << data;
+ }
+ }
+ catch (...)
+ {
+ m.output_manager()->stdout_stream() << "Removing " << config_filename_file << "..." << std::endl;
+ config_filename_file.unlink();
+ throw;
+ }
}
template class PrivateImplementationPattern<repository_repository::RepositoryRepository>;