fix bug in torrent_info::rename_file
This commit is contained in:
parent
8cb18d39a1
commit
587e888152
|
@ -223,7 +223,7 @@ namespace libtorrent
|
|||
void rename_file(int index, std::string const& new_filename)
|
||||
{
|
||||
TORRENT_ASSERT(is_loaded());
|
||||
if (m_files.file_name(index) == new_filename) return;
|
||||
if (m_files.file_path(index) == new_filename) return;
|
||||
copy_on_write();
|
||||
m_files.rename_file(index, new_filename);
|
||||
}
|
||||
|
|
|
@ -264,4 +264,25 @@ TORRENT_TEST(torrent)
|
|||
|
||||
}
|
||||
|
||||
TORRENT_TEST(rename_file)
|
||||
{
|
||||
file_storage fs;
|
||||
|
||||
fs.add_file("test3/tmp1", 0);
|
||||
fs.add_file("test3/tmp2", 0);
|
||||
libtorrent::create_torrent t(fs, 128 * 1024, 6);
|
||||
|
||||
std::vector<char> tmp;
|
||||
std::back_insert_iterator<std::vector<char> > out(tmp);
|
||||
bencode(out, t.generate());
|
||||
error_code ec;
|
||||
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0));
|
||||
|
||||
TEST_EQUAL(info->files().file_path(0), "test3/tmp1");
|
||||
|
||||
// move "test3/tmp1" -> "tmp1"
|
||||
info->rename_file(0, "tmp1");
|
||||
|
||||
TEST_EQUAL(info->files().file_path(0), "tmp1");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue