fix throttling on slow machines
This commit is contained in:
parent
d0197351ab
commit
e5c2fc201e
|
|
@ -116,6 +116,20 @@ initiate(const Filename &source_file, const Filename &dest_file) {
|
|||
|
||||
ofstream *dest_fstream = new ofstream;
|
||||
_dest = dest_fstream;
|
||||
if (dest_filename.exists()) {
|
||||
downloader_cat.info()
|
||||
<< dest_filename << " already exists, removing.\n";
|
||||
if (!dest_filename.unlink()) {
|
||||
downloader_cat.error()
|
||||
<< "Unable to remove old " << dest_filename << "\n";
|
||||
return get_write_error();
|
||||
}
|
||||
} else {
|
||||
if (downloader_cat.is_debug()) {
|
||||
downloader_cat.debug()
|
||||
<< dest_filename << " does not already exist.\n";
|
||||
}
|
||||
}
|
||||
if (!dest_filename.open_write(*dest_fstream)) {
|
||||
downloader_cat.error()
|
||||
<< "Unable to write to " << dest_filename << "\n";
|
||||
|
|
|
|||
|
|
@ -224,8 +224,15 @@ run() {
|
|||
// Come back later.
|
||||
return true;
|
||||
}
|
||||
int num_potential_updates = (int)(elapsed / _seconds_per_update);
|
||||
_last_run_time = now;
|
||||
_bytes_requested += _bytes_per_update;
|
||||
_bytes_requested += _bytes_per_update * num_potential_updates;
|
||||
if (downloader_cat.is_spam()) {
|
||||
downloader_cat.spam()
|
||||
<< "elapsed = " << elapsed << " num_potential_updates = "
|
||||
<< num_potential_updates << " bytes_requested = "
|
||||
<< _bytes_requested << "\n";
|
||||
}
|
||||
}
|
||||
switch (_download_dest) {
|
||||
case DD_none:
|
||||
|
|
@ -568,6 +575,7 @@ reached_done_state() {
|
|||
return false;
|
||||
} else {
|
||||
_started_download = true;
|
||||
_last_run_time = ClockObject::get_global_clock()->get_real_time();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue