diff --git a/ChangeLog b/ChangeLog index 107d87ceb..7ea39b283 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * fix exporting files from partfile while seeding * fix potential deadlock on Windows, caused by performing restricted tasks from within DllMain * fix issue when subsequent file priority updates cause torrent to stop diff --git a/src/torrent.cpp b/src/torrent.cpp index 2c251489a..3fe1e05f0 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5704,8 +5704,6 @@ namespace { { INVARIANT_CHECK; - if (is_seed()) return; - std::vector const new_priority = fix_priorities(files , valid_metadata() ? &m_torrent_file->files() : NULL); @@ -5726,8 +5724,6 @@ namespace { { INVARIANT_CHECK; - if (is_seed()) return; - // setting file priority on a torrent that doesn't have metadata yet is // similar to having passed in file priorities through add_torrent_params. // we store the priorities in m_file_priority until we get the metadata diff --git a/test/test_priority.cpp b/test/test_priority.cpp index 79a9d7551..1c9943645 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -452,3 +452,53 @@ TORRENT_TEST(no_metadata_piece_prio) 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"); + boost::shared_ptr t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false); + file.close(); + + add_torrent_params addp; + addp.flags &= ~add_torrent_params::flag_paused; + addp.flags &= ~add_torrent_params::flag_auto_managed; + addp.save_path = "."; + addp.ti = t; + torrent_handle h = ses.add_torrent(addp); + + // write to the partfile + h.file_priority(0, 0); + + std::vector piece(16 * 1024); + for (int i = 0; i < int(piece.size()); ++i) + piece[i] = (i % 26) + 'A'; + + for (int i = 0; i < t->num_pieces(); ++i) + h.add_piece(i, &piece[0], piece.size()); + + TEST_CHECK(!exists("temporary")); + + for (int i = 0; i < 10; ++i) + { + if (h.status().is_seeding) break; + test_sleep(100); + } + TEST_EQUAL(h.status().is_seeding, true); + + // this should cause the file to be exported + h.file_priority(0, 1); + + for (int i = 0; i < 10; ++i) + { + if (h.file_priority(0) == 1) break; + test_sleep(100); + } + + TEST_CHECK(exists("temporary")); +} +