prevent torrent optimization in unit test
This commit is contained in:
parent
8aa43b682b
commit
d506bcd5de
|
@ -69,7 +69,10 @@ namespace libtorrent
|
||||||
|
|
||||||
struct TORRENT_EXPORT create_torrent
|
struct TORRENT_EXPORT create_torrent
|
||||||
{
|
{
|
||||||
create_torrent(file_storage& fs, int piece_size = 0, int pad_file_limit = -1);
|
enum { optimize = 1 };
|
||||||
|
|
||||||
|
create_torrent(file_storage& fs, int piece_size = 0
|
||||||
|
, int pad_file_limit = -1, int flags = optimize);
|
||||||
create_torrent(torrent_info const& ti);
|
create_torrent(torrent_info const& ti);
|
||||||
entry generate() const;
|
entry generate() const;
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_torrent::create_torrent(file_storage& fs, int piece_size, int pad_file_limit)
|
create_torrent::create_torrent(file_storage& fs, int piece_size, int pad_file_limit, int flags)
|
||||||
: m_files(fs)
|
: m_files(fs)
|
||||||
, m_creation_date(pt::second_clock::universal_time())
|
, m_creation_date(pt::second_clock::universal_time())
|
||||||
, m_multifile(fs.num_files() > 1)
|
, m_multifile(fs.num_files() > 1)
|
||||||
|
@ -125,7 +125,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
m_files.set_piece_length(piece_size);
|
m_files.set_piece_length(piece_size);
|
||||||
m_files.optimize(pad_file_limit);
|
if (flags & optimize)
|
||||||
|
m_files.optimize(pad_file_limit);
|
||||||
m_files.set_num_pieces(static_cast<int>(
|
m_files.set_num_pieces(static_cast<int>(
|
||||||
(m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length()));
|
(m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length()));
|
||||||
m_piece_hash.resize(m_files.num_pieces());
|
m_piece_hash.resize(m_files.num_pieces());
|
||||||
|
|
|
@ -233,7 +233,7 @@ void test_remove(path const& test_path)
|
||||||
fs.add_file("temp_storage/folder2/test3.tmp", 0);
|
fs.add_file("temp_storage/folder2/test3.tmp", 0);
|
||||||
fs.add_file("temp_storage/_folder3/test4.tmp", 0);
|
fs.add_file("temp_storage/_folder3/test4.tmp", 0);
|
||||||
fs.add_file("temp_storage/_folder3/subfolder/test5.tmp", 8);
|
fs.add_file("temp_storage/_folder3/subfolder/test5.tmp", 8);
|
||||||
libtorrent::create_torrent t(fs, 4);
|
libtorrent::create_torrent t(fs, 4, -1, 0);
|
||||||
|
|
||||||
char buf[4] = {0, 0, 0, 0};
|
char buf[4] = {0, 0, 0, 0};
|
||||||
sha1_hash h = hasher(buf, 4).final();
|
sha1_hash h = hasher(buf, 4).final();
|
||||||
|
@ -287,7 +287,7 @@ void test_check_files(path const& test_path
|
||||||
std::generate(piece0, piece0 + piece_size, std::rand);
|
std::generate(piece0, piece0 + piece_size, std::rand);
|
||||||
std::generate(piece2, piece2 + piece_size, std::rand);
|
std::generate(piece2, piece2 + piece_size, std::rand);
|
||||||
|
|
||||||
libtorrent::create_torrent t(fs, piece_size);
|
libtorrent::create_torrent t(fs, piece_size, -1, 0);
|
||||||
t.set_hash(0, hasher(piece0, piece_size).final());
|
t.set_hash(0, hasher(piece0, piece_size).final());
|
||||||
t.set_hash(1, sha1_hash(0));
|
t.set_hash(1, sha1_hash(0));
|
||||||
t.set_hash(2, sha1_hash(0));
|
t.set_hash(2, sha1_hash(0));
|
||||||
|
@ -350,7 +350,7 @@ void run_test(path const& test_path)
|
||||||
fs.add_file("temp_storage/test4.tmp", 0);
|
fs.add_file("temp_storage/test4.tmp", 0);
|
||||||
fs.add_file("temp_storage/test5.tmp", 1);
|
fs.add_file("temp_storage/test5.tmp", 1);
|
||||||
|
|
||||||
libtorrent::create_torrent t(fs, piece_size);
|
libtorrent::create_torrent t(fs, piece_size, -1, 0);
|
||||||
t.set_hash(0, hasher(piece0, piece_size).final());
|
t.set_hash(0, hasher(piece0, piece_size).final());
|
||||||
t.set_hash(1, hasher(piece1, piece_size).final());
|
t.set_hash(1, hasher(piece1, piece_size).final());
|
||||||
t.set_hash(2, hasher(piece2, piece_size).final());
|
t.set_hash(2, hasher(piece2, piece_size).final());
|
||||||
|
@ -376,7 +376,7 @@ void run_test(path const& test_path)
|
||||||
{
|
{
|
||||||
file_storage fs;
|
file_storage fs;
|
||||||
fs.add_file("temp_storage/test1.tmp", 17 + 612 + 1);
|
fs.add_file("temp_storage/test1.tmp", 17 + 612 + 1);
|
||||||
libtorrent::create_torrent t(fs, piece_size);
|
libtorrent::create_torrent t(fs, piece_size, -1, 0);
|
||||||
TEST_CHECK(fs.begin()->path == "temp_storage/test1.tmp");
|
TEST_CHECK(fs.begin()->path == "temp_storage/test1.tmp");
|
||||||
t.set_hash(0, hasher(piece0, piece_size).final());
|
t.set_hash(0, hasher(piece0, piece_size).final());
|
||||||
t.set_hash(1, hasher(piece1, piece_size).final());
|
t.set_hash(1, hasher(piece1, piece_size).final());
|
||||||
|
|
Loading…
Reference in New Issue