Fixed bug when moving storage with files renamed to end up outside of the rood directory. Fixes Deluge bug http://dev.deluge-torrent.org/ticket/839

This commit is contained in:
Arvid Norberg
2009-03-17 09:31:30 +00:00
parent 4ae27edb89
commit 1cdfe26630
3 changed files with 72 additions and 47 deletions

View File

@@ -199,30 +199,11 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
ios.reset();
ios.poll(ec);
// test move_storage
boost::function<void(int, disk_io_job const&)> none;
TEST_CHECK(exists(test_path / "temp_storage"));
pm->async_move_storage(test_path / "temp_storage2", bind(on_move_storage, _1, _2, (test_path / "temp_storage2").string()));
test_sleep(2000);
ios.reset();
ios.poll(ec);
TEST_CHECK(!exists(test_path / "temp_storage"));
TEST_CHECK(exists(test_path / "temp_storage2/temp_storage"));
pm->async_move_storage(test_path, bind(on_move_storage, _1, _2, test_path.string()));
test_sleep(1000);
ios.reset();
ios.poll(ec);
TEST_CHECK(!exists(test_path / "temp_storage2/temp_storage"));
remove_all(test_path / "temp_storage2");
// test rename_file
remove(test_path / "part0");
TEST_CHECK(exists(test_path / "temp_storage/test1.tmp"));
TEST_CHECK(!exists(test_path / "part0"));
boost::function<void(int, disk_io_job const&)> none;
pm->async_rename_file(0, "part0", none);
test_sleep(1000);
@@ -232,6 +213,31 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
TEST_CHECK(!exists(test_path / "temp_storage/test1.tmp"));
TEST_CHECK(exists(test_path / "part0"));
// test move_storage with two files in the root directory
TEST_CHECK(exists(test_path / "temp_storage"));
pm->async_move_storage(test_path / "temp_storage2", bind(on_move_storage, _1, _2, (test_path / "temp_storage2").string()));
test_sleep(2000);
ios.reset();
ios.poll(ec);
if (fs.num_files() > 1)
{
TEST_CHECK(!exists(test_path / "temp_storage"));
TEST_CHECK(exists(test_path / "temp_storage2/temp_storage"));
}
TEST_CHECK(exists(test_path / "temp_storage2/part0"));
pm->async_move_storage(test_path, bind(on_move_storage, _1, _2, test_path.string()));
test_sleep(2000);
ios.reset();
ios.poll(ec);
TEST_CHECK(exists(test_path / "part0"));
TEST_CHECK(!exists(test_path / "temp_storage2/temp_storage"));
TEST_CHECK(!exists(test_path / "temp_storage2/part0"));
peer_request r;
r.piece = 0;
r.start = 0;
@@ -244,7 +250,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
pm->async_release_files(none);
pm->async_rename_file(0, "temp_storage/test1.tmp", none);
test_sleep(1000);
test_sleep(2000);
ios.reset();
ios.poll(ec);
@@ -254,6 +260,8 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
ios.run(ec);
io.join();
remove_all(test_path / "temp_storage2");
remove_all(test_path / "part0");
}
page_aligned_allocator::free(piece);
}