From 7e17841ed3ed2fa7887293d3e41fdbbef9d56321 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 30 Oct 2002 23:56:51 +0000 Subject: [PATCH] use new truncate parameter for open_write --- panda/src/downloader/decompressor.cxx | 2 +- panda/src/downloader/httpChannel.cxx | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index 13859929fc..d928744720 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -131,7 +131,7 @@ initiate(const Filename &source_file, const Filename &dest_file) { << dest_filename << " does not already exist.\n"; } } - if (!dest_filename.open_write(*dest_fstream)) { + if (!dest_filename.open_write(*dest_fstream, true)) { downloader_cat.error() << "Unable to write to " << dest_filename << "\n"; return get_write_error(); diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 936202badd..346e425315 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -435,10 +435,12 @@ download_to_file(const Filename &filename, size_t first_byte) { _download_to_filename.set_binary(); _download_to_file.close(); _download_to_file.clear(); + + bool truncate = (first_byte == 0); - if (!_download_to_filename.open_write(_download_to_file)) { + if (!_download_to_filename.open_write(_download_to_file, truncate)) { downloader_cat.info() - << "Could not open " << filename << " for writing.\n"; + << "Could not open " << _download_to_filename << " for writing.\n"; return false; } @@ -1341,6 +1343,7 @@ run_download_to_file() { int count = 0; int ch = _body_stream->get(); + nassertr(_body_stream != (ISocketStream *)NULL, false); while (!_body_stream->eof() && !_body_stream->fail()) { _download_to_file.put(ch); _bytes_downloaded++; @@ -1350,6 +1353,7 @@ run_download_to_file() { } ch = _body_stream->get(); + nassertr(_body_stream != (ISocketStream *)NULL, false); } if (_download_to_file.fail()) { @@ -1385,6 +1389,7 @@ run_download_to_ram() { int count = 0; int ch = _body_stream->get(); + nassertr(_body_stream != (ISocketStream *)NULL, false); while (!_body_stream->eof() && !_body_stream->fail()) { _download_to_ramfile->_data += (char)ch; _bytes_downloaded++; @@ -1394,6 +1399,7 @@ run_download_to_ram() { } ch = _body_stream->get(); + nassertr(_body_stream != (ISocketStream *)NULL, false); } if (_body_stream->is_closed()) { @@ -1513,7 +1519,7 @@ reset_for_new_request() { //////////////////////////////////////////////////////////////////// void HTTPChannel:: finished_body(bool has_trailer) { - if (will_close_connection()) { + if (will_close_connection() && _download_dest == DD_none) { reset_to_new(); } else {