fix bug in hash_picker with empty files

This commit is contained in:
arvidn
2022-09-23 15:39:34 +02:00
committed by Arvid Norberg
parent e950d14775
commit 31cedce075
3 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,4 @@
* fix bug in hash_picker with empty files
* uTP performance, prevent premature timeouts/resends
* add option to not memory map files below a certain size
* settings_pack now returns default values when queried for missing settings

View File

@ -547,3 +547,9 @@ TORRENT_TEST(small_file_large_piece)
run_torrent_test(test_torrent(make_files(
{{0x833ed, false}, {0x7cc13, true}, {0x3d, false}, {0x7ffc3, true}, {0x14000, false}}, 0x80000), {}));
}
TORRENT_TEST(empty_file)
{
run_torrent_test(test_torrent(make_files(
{{0x3000, false}, {0, false}, {0x8000, false}}, 0x4000), {}));
}

View File

@ -181,9 +181,9 @@ bool validate_hash_request(hash_request const& hr, file_storage const& fs)
}
}
for (file_index_t fidx(0); fidx < m_piece_hash_requested.end_index(); ++fidx)
for (auto const fidx : m_piece_hash_requested.range())
{
if (m_files.pad_file_at(fidx)) continue;
if (m_files.pad_file_at(fidx) || m_files.file_size(fidx) == 0) continue;
int const file_first_piece = int(m_files.file_offset(fidx) / m_files.piece_length());
int const num_layers = file_num_layers(fidx);