improve handling of case where a torrent file has no files in it

This commit is contained in:
arvidn 2017-10-01 05:15:27 +02:00 committed by Arvid Norberg
parent 5026659cb6
commit 33b03e1f8e
3 changed files with 9 additions and 0 deletions

View File

@ -1000,6 +1000,13 @@ namespace {
}
m_flags |= multifile;
}
if (files.num_files() == 0)
{
ec = errors::no_files_in_torrent;
// mark the torrent as invalid
m_files.set_piece_length(0);
return false;
}
TORRENT_ASSERT(!files.name().empty());
// extract SHA-1 hashes for all pieces

View File

@ -155,6 +155,7 @@ test_failing_torrent_t test_error_torrents[] =
{ "invalid_file_size.torrent", errors::torrent_invalid_length },
{ "invalid_symlink.torrent", errors::torrent_invalid_name },
{ "many_pieces.torrent", errors::too_many_pieces_in_torrent },
{ "no_files.torrent", errors::no_files_in_torrent},
};
// TODO: test remap_files

View File

@ -0,0 +1 @@
d10:created by10:libtorrent13:creation datei1359599503e4:infod5:filesle4:name4:temp12:piece lengthi16384e6:pieces20:‚ž¼Œ&¾ÇJW}ÜA4u,·¼‡ee