diff --git a/ChangeLog b/ChangeLog index b1da58fea..21fedb5aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/torrent.cpp b/src/torrent.cpp index 32d1607a7..88c2883af 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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(done) / m_torrent_file.file_at(i).size; } }