prevent occasional assertion failure

This commit is contained in:
David Rose 2009-01-27 06:27:47 +00:00
parent 36c0a0fd2e
commit f6030da8bc

View File

@ -244,6 +244,7 @@ store(BamCacheRecord *record) {
return false;
}
{
BamWriter writer(&dout, temp_pathname);
if (!writer.init()) {
temp_pathname.unlink();
@ -270,6 +271,11 @@ store(BamCacheRecord *record) {
return false;
}
// Now that we are done with the BamWriter, it's important to let
// it destruct now and clean itself up, or it might get mad if we
// delete any TypedWritables below that haven't been written yet.
}
record->_record_size = temp_file.tellp();
temp_file.close();
@ -752,6 +758,7 @@ do_write_index(Filename &index_pathname, const BamCacheIndex *index) {
return false;
}
{
BamWriter writer(&dout, index_pathname);
if (!writer.init()) {
index_pathname.unlink();
@ -762,6 +769,7 @@ do_write_index(Filename &index_pathname, const BamCacheIndex *index) {
index_pathname.unlink();
return false;
}
}
index_file.close();
return true;