From 8346841d35a76b79da368f486a823d8721455ba0 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 8 Oct 2006 20:36:05 +0000 Subject: [PATCH] fixed bug in file_progress with file sizes of 0 bytes --- ChangeLog | 1 + src/torrent.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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; } }