fixed bug in file_progress with file sizes of 0 bytes

This commit is contained in:
Arvid Norberg 2006-10-08 20:36:05 +00:00
parent 8e0d7a3bc8
commit 8346841d35
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,4 @@
* fixed bug with file_progress() with files = 0 bytes
* fixed a race condition bug in udp_tracker_connection that could
cause a crash.
* fixed bug occuring when increasing the sequenced download threshold

View File

@ -1780,6 +1780,15 @@ namespace libtorrent
{
peer_request ret = m_torrent_file.map_file(i, 0, 0);
size_type size = m_torrent_file.file_at(i).size;
// zero sized files are considered
// 100% done all the time
if (size == 0)
{
fp[i] = 1.f;
continue;
}
size_type done = 0;
while (size > 0)
{
@ -1791,7 +1800,7 @@ namespace libtorrent
size -= bytes_step;
}
assert(size == 0);
fp[i] = static_cast<float>(done) / m_torrent_file.file_at(i).size;
}
}