aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-07-24 22:54:18 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-07-24 22:54:18 +0000
commitb64b94e1c003d681efbc599c20fbd8e20f375a9b (patch)
treeb334dda46722dd94d994ad5b6689e4eba82a0287
parent94f91d3b2914dba2b8fe59d7ec6fda61716bdeaa (diff)
downloadpaludis-b64b94e1c003d681efbc599c20fbd8e20f375a9b.tar.gz
paludis-b64b94e1c003d681efbc599c20fbd8e20f375a9b.tar.xz
Don't die if an exception occurs while writing a cache file.
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index 56678c0..b8c3c57 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -174,11 +174,12 @@ EbuildFlatMetadataCache::save(const tr1::shared_ptr<const EbuildID> & id)
}
catch (const FSError &)
{
- // let the 'if (cache)' handle the error
+ // let the 'if (cache_file)' handle the error
}
- std::ofstream cache(stringify(_filename).c_str());
- if (cache)
+ std::ostringstream cache;
+
+ try
{
if (id->build_dependencies_key())
cache << flatten(id->build_dependencies_key()->value()) << std::endl;
@@ -246,6 +247,17 @@ EbuildFlatMetadataCache::save(const tr1::shared_ptr<const EbuildID> & id)
cache << normalise(id->eapi()->name) << std::endl;
}
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "Not writing cache file to '"
+ << _filename << "' due to exception '" << e.message() << "' (" << e.what() << ")";
+ return;
+ }
+
+ std::ofstream cache_file(stringify(_filename).c_str());
+
+ if (cache_file)
+ cache_file << cache.str();
else
{
Log::get_instance()->message(ll_warning, lc_no_context) << "Couldn't write cache file to '"