forked from premiere/premiere-libtorrent
merged RC_1_1 into master
This commit is contained in:
commit
828c5dd097
|
@ -87,6 +87,7 @@
|
||||||
* resume data no longer has timestamps of files
|
* resume data no longer has timestamps of files
|
||||||
* require C++11 to build libtorrent
|
* require C++11 to build libtorrent
|
||||||
|
|
||||||
|
* fix exporting files from partfile while seeding
|
||||||
* fix potential deadlock on Windows, caused by performing restricted
|
* fix potential deadlock on Windows, caused by performing restricted
|
||||||
tasks from within DllMain
|
tasks from within DllMain
|
||||||
* fix issue when subsequent file priority updates cause torrent to stop
|
* fix issue when subsequent file priority updates cause torrent to stop
|
||||||
|
|
|
@ -3546,7 +3546,7 @@ bool is_downloading_state(int const st)
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
|
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
|
||||||
st.total_wanted_done = std::int64_t(num_passed() - m_picker->num_have_filtered())
|
st.total_wanted_done = std::int64_t(num_have() - m_picker->num_have_filtered())
|
||||||
* piece_size;
|
* piece_size;
|
||||||
TORRENT_ASSERT(st.total_wanted_done >= 0);
|
TORRENT_ASSERT(st.total_wanted_done >= 0);
|
||||||
|
|
||||||
|
@ -3580,7 +3580,7 @@ bool is_downloading_state(int const st)
|
||||||
st.total_done += corr;
|
st.total_done += corr;
|
||||||
if (m_picker->piece_priority(last_piece) != dont_download)
|
if (m_picker->piece_priority(last_piece) != dont_download)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(st.total_wanted_done >= piece_size);
|
TORRENT_ASSERT(st.total_wanted_done >= -corr);
|
||||||
st.total_wanted_done += corr;
|
st.total_wanted_done += corr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3600,7 +3600,7 @@ bool is_downloading_state(int const st)
|
||||||
for (piece_index_t j = p.piece; p.length > 0; ++j)
|
for (piece_index_t j = p.piece; p.length > 0; ++j)
|
||||||
{
|
{
|
||||||
int const deduction = std::min(p.length, piece_size - p.start);
|
int const deduction = std::min(p.length, piece_size - p.start);
|
||||||
bool const done = m_picker->has_piece_passed(j);
|
bool const done = m_picker->have_piece(j);
|
||||||
bool const wanted = m_picker->piece_priority(j) > dont_download;
|
bool const wanted = m_picker->piece_priority(j) > dont_download;
|
||||||
if (done) st.total_done -= deduction;
|
if (done) st.total_done -= deduction;
|
||||||
if (wanted) st.total_wanted -= deduction;
|
if (wanted) st.total_wanted -= deduction;
|
||||||
|
@ -5029,8 +5029,6 @@ bool is_downloading_state(int const st)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (is_seed()) return;
|
|
||||||
|
|
||||||
auto new_priority = fix_priorities(files
|
auto new_priority = fix_priorities(files
|
||||||
, valid_metadata() ? &m_torrent_file->files() : nullptr);
|
, valid_metadata() ? &m_torrent_file->files() : nullptr);
|
||||||
|
|
||||||
|
@ -5052,8 +5050,6 @@ bool is_downloading_state(int const st)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (is_seed()) return;
|
|
||||||
|
|
||||||
// setting file priority on a torrent that doesn't have metadata yet is
|
// setting file priority on a torrent that doesn't have metadata yet is
|
||||||
// similar to having passed in file priorities through add_torrent_params.
|
// similar to having passed in file priorities through add_torrent_params.
|
||||||
// we store the priorities in m_file_priority until we get the metadata
|
// we store the priorities in m_file_priority until we get the metadata
|
||||||
|
@ -7439,8 +7435,8 @@ bool is_downloading_state(int const st)
|
||||||
m_file_progress.clear();
|
m_file_progress.clear();
|
||||||
}
|
}
|
||||||
m_have_all = true;
|
m_have_all = true;
|
||||||
update_gauge();
|
|
||||||
}
|
}
|
||||||
|
update_gauge();
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when torrent is complete. i.e. all pieces downloaded
|
// called when torrent is complete. i.e. all pieces downloaded
|
||||||
|
@ -10789,7 +10785,12 @@ bool is_downloading_state(int const st)
|
||||||
if (st->state == torrent_status::finished
|
if (st->state == torrent_status::finished
|
||||||
|| st->state == torrent_status::seeding)
|
|| st->state == torrent_status::seeding)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(st->is_finished);
|
// this assumption does not always hold. We transition to "finished"
|
||||||
|
// when we receive the last block of the last piece, which is before
|
||||||
|
// the hash check comes back. "is_finished" is set to true once all the
|
||||||
|
// pieces have been hash checked. So, there's a short window where it
|
||||||
|
// doesn't hold.
|
||||||
|
// TORRENT_ASSERT(st->is_finished);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -479,3 +479,53 @@ TORRENT_TEST(no_metadata_piece_prio)
|
||||||
|
|
||||||
ses.remove_torrent(h);
|
ses.remove_torrent(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORRENT_TEST(export_file_while_seed)
|
||||||
|
{
|
||||||
|
settings_pack pack = settings();
|
||||||
|
lt::session ses(pack);
|
||||||
|
|
||||||
|
error_code ec;
|
||||||
|
create_directory("tmp2_priority", ec);
|
||||||
|
std::ofstream file("tmp2_priority/temporary");
|
||||||
|
auto t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
add_torrent_params addp;
|
||||||
|
addp.flags &= ~torrent_flags::paused;
|
||||||
|
addp.flags &= ~torrent_flags::auto_managed;
|
||||||
|
addp.save_path = ".";
|
||||||
|
addp.ti = t;
|
||||||
|
torrent_handle h = ses.add_torrent(addp);
|
||||||
|
|
||||||
|
// write to the partfile
|
||||||
|
h.file_priority(file_index_t{0}, lt::dont_download);
|
||||||
|
|
||||||
|
std::vector<char> piece(16 * 1024);
|
||||||
|
for (int i = 0; i < int(piece.size()); ++i)
|
||||||
|
piece[std::size_t(i)] = char((i % 26) + 'A');
|
||||||
|
|
||||||
|
for (piece_index_t i : t->piece_range())
|
||||||
|
h.add_piece(i, piece.data());
|
||||||
|
|
||||||
|
TEST_CHECK(!exists("temporary"));
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
if (h.status().is_seeding) break;
|
||||||
|
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||||
|
}
|
||||||
|
TEST_EQUAL(h.status().is_seeding, true);
|
||||||
|
|
||||||
|
// this should cause the file to be exported
|
||||||
|
h.file_priority(file_index_t{0}, lt::low_priority);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
if (h.file_priority(file_index_t{0}) == lt::low_priority) break;
|
||||||
|
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CHECK(exists("temporary"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue