forked from premiere/premiere-libtorrent
move storage fix
This commit is contained in:
parent
db9236fcf8
commit
36eb9c4f51
|
@ -1314,7 +1314,7 @@ namespace libtorrent
|
|||
m_log << log_time() << " move" << std::endl;
|
||||
#endif
|
||||
TORRENT_ASSERT(j.buffer == 0);
|
||||
ret = j.storage->move_storage_impl(j.str) ? 1 : 0;
|
||||
ret = j.storage->move_storage_impl(j.str) ? 0 : 1;
|
||||
if (ret != 0)
|
||||
{
|
||||
test_error(j);
|
||||
|
|
|
@ -141,6 +141,10 @@ void test_transfer()
|
|||
ses2.set_alert_mask(alert::all_categories & ~alert::progress_notification);
|
||||
ses1.set_alert_dispatch(&print_alert);
|
||||
|
||||
// also test to move the storage of the downloader and the uploader
|
||||
// to make sure it can handle switching paths
|
||||
bool test_move_storage = false;
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
print_alerts(ses1, "ses1");
|
||||
|
@ -163,6 +167,14 @@ void test_transfer()
|
|||
|
||||
if (tor2.is_finished()) break;
|
||||
|
||||
if (!test_move_storage && st2.progress > 0.25f)
|
||||
{
|
||||
test_move_storage = true;
|
||||
tor1.move_storage("./tmp1_transfer_moved");
|
||||
tor2.move_storage("./tmp2_transfer_moved");
|
||||
std::cerr << "moving storage" << std::endl;
|
||||
}
|
||||
|
||||
TEST_CHECK(st1.state == torrent_status::seeding
|
||||
|| st1.state == torrent_status::checking_files);
|
||||
TEST_CHECK(st2.state == torrent_status::downloading);
|
||||
|
@ -234,7 +246,7 @@ void test_transfer()
|
|||
std::cout << "re-adding" << std::endl;
|
||||
add_torrent_params p;
|
||||
p.ti = t;
|
||||
p.save_path = "./tmp2_transfer";
|
||||
p.save_path = "./tmp2_transfer_moved";
|
||||
p.resume_data = &resume_data;
|
||||
tor2 = ses2.add_torrent(p);
|
||||
ses2.set_alert_mask(alert::all_categories & ~alert::progress_notification);
|
||||
|
@ -303,6 +315,8 @@ int test_main()
|
|||
// in case the previous run was terminated
|
||||
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
|
||||
|
||||
#ifdef NDEBUG
|
||||
// test rate only makes sense in release mode
|
||||
|
@ -310,12 +324,16 @@ int test_main()
|
|||
|
||||
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
|
||||
#endif
|
||||
|
||||
test_transfer();
|
||||
|
||||
try { remove_all("./tmp1_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp1_transfer_moved"); } catch (std::exception&) {}
|
||||
try { remove_all("./tmp2_transfer_moved"); } catch (std::exception&) {}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue