Merge branch 'RC_1_1'

This commit is contained in:
arvidn 2016-02-20 01:58:39 -05:00
commit 1710b7c750
1 changed files with 41 additions and 23 deletions

View File

@ -7211,8 +7211,25 @@ namespace libtorrent
// for the piece // for the piece
// bit 0: set if we have the piece // bit 0: set if we have the piece
// bit 1: set if we have verified the piece (in seed mode) // bit 1: set if we have verified the piece (in seed mode)
bool const is_checking = state() == torrent_status::checking_files;
bool const has_checked = state() == torrent_status::downloading
|| state() == torrent_status::finished
|| state() == torrent_status::seeding;
// if we are checking, only save the have_pieces bitfield up to the piece
// we have actually checked. This allows us to resume the checking when we
// load this torrent up again. If we have not completed checking nor is
// currently checking, don't save any pieces from the have_pieces
// bitfield.
int const max_piece
= is_checking ? m_num_checked_pieces
: has_checked ? m_torrent_file->num_pieces()
: 0;
if (max_piece > 0)
{
entry::string_type& pieces = ret["pieces"].string(); entry::string_type& pieces = ret["pieces"].string();
pieces.resize(m_torrent_file->num_pieces()); pieces.resize(max_piece);
if (!has_picker()) if (!has_picker())
{ {
std::memset(&pieces[0], m_have_all, pieces.size()); std::memset(&pieces[0], m_have_all, pieces.size());
@ -7230,6 +7247,7 @@ namespace libtorrent
for (int i = 0, end(pieces.size()); i < end; ++i) for (int i = 0, end(pieces.size()); i < end; ++i)
pieces[i] |= m_verified[i] ? 2 : 0; pieces[i] |= m_verified[i] ? 2 : 0;
} }
}
// write renamed files // write renamed files
if (&m_torrent_file->files() != &m_torrent_file->orig_files() if (&m_torrent_file->files() != &m_torrent_file->orig_files()