mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-05 16:08:40 +00:00
lt sync torrent.cpp r2541 - file_progress fixes
This commit is contained in:
parent
32e3481ef1
commit
a100b84ebd
1 changed files with 28 additions and 7 deletions
|
@ -875,7 +875,7 @@ namespace libtorrent
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<tracker_logger> tl(new tracker_logger(m_ses));
|
boost::shared_ptr<aux::tracker_logger> tl(new aux::tracker_logger(m_ses));
|
||||||
m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
|
m_ses.m_tracker_manager.queue_request(m_ses.m_io_service, m_ses.m_half_open, req
|
||||||
, tracker_login(), m_ses.m_listen_interface.address(), tl);
|
, tracker_login(), m_ses.m_listen_interface.address(), tl);
|
||||||
}
|
}
|
||||||
|
@ -4120,8 +4120,16 @@ namespace libtorrent
|
||||||
piece_picker::block_info const* info = i->info;
|
piece_picker::block_info const* info = i->info;
|
||||||
for (int k = 0; k < num_blocks; ++k)
|
for (int k = 0; k < num_blocks; ++k)
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT(file != m_torrent_file->end_files());
|
||||||
TORRENT_ASSERT(offset == size_type(i->index) * m_torrent_file->piece_length()
|
TORRENT_ASSERT(offset == size_type(i->index) * m_torrent_file->piece_length()
|
||||||
+ k * m_block_size);
|
+ k * m_block_size);
|
||||||
|
TORRENT_ASSERT(offset < m_torrent_file->total_size());
|
||||||
|
while (offset >= file->offset + file->size)
|
||||||
|
{
|
||||||
|
++file;
|
||||||
|
++file_index;
|
||||||
|
}
|
||||||
|
TORRENT_ASSERT(file != m_torrent_file->end_files());
|
||||||
|
|
||||||
size_type block_size = m_block_size;
|
size_type block_size = m_block_size;
|
||||||
|
|
||||||
|
@ -4141,6 +4149,7 @@ namespace libtorrent
|
||||||
= p->connection->downloading_piece_progress();
|
= p->connection->downloading_piece_progress();
|
||||||
if (pbp && pbp->piece_index == i->index && pbp->block_index == k)
|
if (pbp && pbp->piece_index == i->index && pbp->block_index == k)
|
||||||
block_size = pbp->bytes_downloaded;
|
block_size = pbp->bytes_downloaded;
|
||||||
|
TORRENT_ASSERT(block_size <= m_block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block_size == 0)
|
if (block_size == 0)
|
||||||
|
@ -4150,28 +4159,40 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + m_block_size > file->offset + file->size)
|
if (offset + block_size > file->offset + file->size)
|
||||||
{
|
{
|
||||||
int left_over = m_block_size - block_size;
|
int left_over = m_block_size - block_size;
|
||||||
// split the block on multiple files
|
// split the block on multiple files
|
||||||
while (offset + block_size > file->offset + file->size)
|
while (block_size > 0)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(offset <= file->offset + file->size);
|
TORRENT_ASSERT(offset <= file->offset + file->size);
|
||||||
size_type slice = file->offset + file->size - offset;
|
size_type slice = (std::min)(file->offset + file->size - offset
|
||||||
|
, block_size);
|
||||||
fp[file_index] += slice;
|
fp[file_index] += slice;
|
||||||
offset += slice;
|
offset += slice;
|
||||||
block_size -= slice;
|
block_size -= slice;
|
||||||
|
TORRENT_ASSERT(offset <= file->offset + file->size);
|
||||||
|
if (offset == file->offset + file->size)
|
||||||
|
{
|
||||||
++file;
|
++file;
|
||||||
++file_index;
|
++file_index;
|
||||||
if (file == m_torrent_file->end_files()) break;
|
if (file == m_torrent_file->end_files())
|
||||||
|
{
|
||||||
|
offset += block_size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
offset += left_over;
|
offset += left_over;
|
||||||
|
TORRENT_ASSERT(offset == size_type(i->index) * m_torrent_file->piece_length()
|
||||||
|
+ (k+1) * m_block_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fp[file_index] += block_size;
|
fp[file_index] += block_size;
|
||||||
offset += m_block_size;
|
offset += m_block_size;
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(file_index <= m_torrent_file->num_files());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue