use new truncate parameter for open_write
This commit is contained in:
parent
35afd13237
commit
7e17841ed3
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue