forked from premiere/premiere-libtorrent
back-port fix adding empty file as torrent
This commit is contained in:
parent
53bd03558c
commit
c292696dcb
|
@ -4929,6 +4929,12 @@ retry:
|
|||
params.ti = t;
|
||||
}
|
||||
|
||||
if (params.ti && !params.ti->is_valid())
|
||||
{
|
||||
ec = errors::no_metadata;
|
||||
return ptr_t();
|
||||
}
|
||||
|
||||
if (params.ti && params.ti->is_valid() && params.ti->num_files() == 0)
|
||||
{
|
||||
ec = errors::no_files_in_torrent;
|
||||
|
|
|
@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/performance_counters.hpp"
|
||||
#include "libtorrent/bdecode.hpp"
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
@ -59,7 +60,6 @@ TORRENT_TEST(session)
|
|||
// verify that we get the appropriate performance warning because
|
||||
// we're allowing a larger queue than we have cache.
|
||||
|
||||
|
||||
alert const* a;
|
||||
for (;;)
|
||||
{
|
||||
|
@ -93,6 +93,23 @@ TORRENT_TEST(session)
|
|||
// the session object
|
||||
}
|
||||
|
||||
TORRENT_TEST(load_empty_file)
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_int(settings_pack::alert_mask, ~0);
|
||||
lt::session ses(p);
|
||||
|
||||
add_torrent_params atp;
|
||||
error_code ignore_errors;
|
||||
atp.ti = boost::make_shared<torrent_info>("", 0, ignore_errors);
|
||||
atp.save_path = ".";
|
||||
error_code ec;
|
||||
torrent_handle h = ses.add_torrent(atp, ec);
|
||||
|
||||
TEST_CHECK(!h.is_valid());
|
||||
TEST_CHECK(ec == error_code(errors::no_metadata))
|
||||
}
|
||||
|
||||
TORRENT_TEST(session_stats)
|
||||
{
|
||||
std::vector<stats_metric> stats = session_stats_metrics();
|
||||
|
@ -107,6 +124,7 @@ TORRENT_TEST(session_stats)
|
|||
TEST_EQUAL(stats[i].value_index, i);
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
|
||||
template <typename Set, typename Save, typename Default, typename Load>
|
||||
|
|
|
@ -854,6 +854,26 @@ TORRENT_TEST(resolve_duplicates)
|
|||
test_resolve_duplicates(i);
|
||||
}
|
||||
|
||||
TORRENT_TEST(empty_file)
|
||||
{
|
||||
error_code ec;
|
||||
boost::shared_ptr<torrent_info> ti = boost::make_shared<torrent_info>("", 0, ec);
|
||||
TEST_CHECK(ec);
|
||||
}
|
||||
|
||||
TORRENT_TEST(empty_file2)
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::shared_ptr<torrent_info> ti = boost::make_shared<torrent_info>("", 0);
|
||||
TEST_ERROR("expected exception thrown");
|
||||
}
|
||||
catch (libtorrent_exception& e)
|
||||
{
|
||||
printf("Expected error: %s\n", e.error().message().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
TORRENT_TEST(copy)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
|
Loading…
Reference in New Issue