fix connection_tester to support generating fake data for arbitrary torrents (#1181)

This commit is contained in:
Arvid Norberg 2016-10-04 07:31:07 -07:00 committed by GitHub
parent 7a52a285a1
commit 15bf443bfd
1 changed files with 2 additions and 1 deletions

View File

@ -840,7 +840,8 @@ void generate_data(char const* path, torrent_info const& ti)
for (int j = 0; j < ti.piece_size(i); j += 0x4000)
{
generate_block(piece, i, j, 0x4000);
file::iovec_t b = { piece, 0x4000};
int const left_in_piece = ti.piece_size(i) - j;
file::iovec_t const b = { piece, size_t(std::min(left_in_piece, 0x4000))};
storage_error error;
st->writev(&b, 1, i, j, 0, error);
if (error)