fixed save path updates when moving torrents. Fixes #310
This commit is contained in:
parent
5314b639e2
commit
3e000a3984
|
@ -321,7 +321,7 @@ namespace libtorrent
|
||||||
int rename_file_impl(int index, std::string const& new_filename)
|
int rename_file_impl(int index, std::string const& new_filename)
|
||||||
{ return m_storage->rename_file(index, new_filename); }
|
{ return m_storage->rename_file(index, new_filename); }
|
||||||
|
|
||||||
bool move_storage_impl(fs::path const& save_path);
|
int move_storage_impl(fs::path const& save_path);
|
||||||
|
|
||||||
int allocate_slot_for_piece(int piece_index);
|
int allocate_slot_for_piece(int piece_index);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -1409,14 +1409,14 @@ namespace libtorrent
|
||||||
return m_storage->hash_for_slot(slot, ph, m_files.piece_size(piece));
|
return m_storage->hash_for_slot(slot, ph, m_files.piece_size(piece));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool piece_manager::move_storage_impl(fs::path const& save_path)
|
int piece_manager::move_storage_impl(fs::path const& save_path)
|
||||||
{
|
{
|
||||||
if (m_storage->move_storage(save_path))
|
if (m_storage->move_storage(save_path))
|
||||||
{
|
{
|
||||||
m_save_path = fs::complete(save_path);
|
m_save_path = fs::complete(save_path);
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void piece_manager::write_resume_data(entry& rd) const
|
void piece_manager::write_resume_data(entry& rd) const
|
||||||
|
|
|
@ -3249,6 +3249,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
alerts().post_alert(storage_moved_alert(get_handle(), j.str));
|
alerts().post_alert(storage_moved_alert(get_handle(), j.str));
|
||||||
}
|
}
|
||||||
|
m_save_path = j.str;
|
||||||
}
|
}
|
||||||
|
|
||||||
piece_manager& torrent::filesystem()
|
piece_manager& torrent::filesystem()
|
||||||
|
|
|
@ -50,6 +50,13 @@ void on_check_files(int ret, disk_io_job const& j)
|
||||||
std::cerr << "on_check_files ret: " << ret << " " << j.piece << std::endl;
|
std::cerr << "on_check_files ret: " << ret << " " << j.piece << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_move_storage(int ret, disk_io_job const& j, std::string path)
|
||||||
|
{
|
||||||
|
std::cerr << "on_move_storage ret: " << ret << " path:" << j.str << std::endl;
|
||||||
|
TEST_CHECK(ret == 0);
|
||||||
|
TEST_CHECK(j.str == path);
|
||||||
|
}
|
||||||
|
|
||||||
void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
||||||
, file_storage& fs
|
, file_storage& fs
|
||||||
, path const& test_path
|
, path const& test_path
|
||||||
|
@ -111,16 +118,26 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
||||||
ios.reset();
|
ios.reset();
|
||||||
ios.run_one();
|
ios.run_one();
|
||||||
}
|
}
|
||||||
|
ios.reset();
|
||||||
|
ios.poll();
|
||||||
|
|
||||||
// test move_storage
|
// test move_storage
|
||||||
boost::function<void(int, disk_io_job const&)> none;
|
boost::function<void(int, disk_io_job const&)> none;
|
||||||
TEST_CHECK(exists(test_path / "temp_storage"));
|
TEST_CHECK(exists(test_path / "temp_storage"));
|
||||||
pm->async_move_storage(test_path / "temp_storage2", none);
|
pm->async_move_storage(test_path / "temp_storage2", bind(on_move_storage, _1, _2, (test_path / "temp_storage2").string()));
|
||||||
|
|
||||||
test_sleep(2000);
|
test_sleep(2000);
|
||||||
|
ios.reset();
|
||||||
|
ios.poll();
|
||||||
|
|
||||||
TEST_CHECK(!exists(test_path / "temp_storage"));
|
TEST_CHECK(!exists(test_path / "temp_storage"));
|
||||||
TEST_CHECK(exists(test_path / "temp_storage2/temp_storage"));
|
TEST_CHECK(exists(test_path / "temp_storage2/temp_storage"));
|
||||||
pm->async_move_storage(test_path, none);
|
pm->async_move_storage(test_path, bind(on_move_storage, _1, _2, test_path.string()));
|
||||||
|
|
||||||
test_sleep(2000);
|
test_sleep(2000);
|
||||||
|
ios.reset();
|
||||||
|
ios.poll();
|
||||||
|
|
||||||
TEST_CHECK(!exists(test_path / "temp_storage2/temp_storage"));
|
TEST_CHECK(!exists(test_path / "temp_storage2/temp_storage"));
|
||||||
remove_all(test_path / "temp_storage2");
|
remove_all(test_path / "temp_storage2");
|
||||||
|
|
||||||
|
@ -129,7 +146,11 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
||||||
TEST_CHECK(exists(test_path / "temp_storage/test1.tmp"));
|
TEST_CHECK(exists(test_path / "temp_storage/test1.tmp"));
|
||||||
TEST_CHECK(!exists(test_path / "part0"));
|
TEST_CHECK(!exists(test_path / "part0"));
|
||||||
pm->async_rename_file(0, "part0", none);
|
pm->async_rename_file(0, "part0", none);
|
||||||
|
|
||||||
test_sleep(2000);
|
test_sleep(2000);
|
||||||
|
ios.reset();
|
||||||
|
ios.poll();
|
||||||
|
|
||||||
TEST_CHECK(!exists(test_path / "temp_storage/test1.tmp"));
|
TEST_CHECK(!exists(test_path / "temp_storage/test1.tmp"));
|
||||||
TEST_CHECK(exists(test_path / "part0"));
|
TEST_CHECK(exists(test_path / "part0"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue