fix file rename issue with name prefix matching torrent name (#1524)
fix file rename issue with name prefix matching torrent name
This commit is contained in:
parent
70a650fc94
commit
2120a13869
|
@ -1,3 +1,4 @@
|
|||
* fix file rename issue with name prefix matching torrent name
|
||||
* fix division by zero when setting tick_interval > 1000
|
||||
* fix move_storage() to its own directory (would delete the files)
|
||||
* fix socks5 support for UDP
|
||||
|
|
|
@ -179,9 +179,9 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
if (branch_len >= m_name.size()
|
||||
&& std::memcmp(branch_path, m_name.c_str(), m_name.size()) == 0)
|
||||
&& std::memcmp(branch_path, m_name.c_str(), m_name.size()) == 0
|
||||
&& branch_path[m_name.size()] == TORRENT_SEPARATOR)
|
||||
{
|
||||
// the +1 is to skip the trailing '/' (or '\')
|
||||
int const offset = m_name.size()
|
||||
+ (m_name.size() == branch_len?0:1);
|
||||
branch_path += offset;
|
||||
|
|
|
@ -50,7 +50,7 @@ void report_failure(char const* err, char const* file, int line)
|
|||
{
|
||||
char buf[500];
|
||||
snprintf(buf, sizeof(buf), "\x1b[41m***** %s:%d \"%s\" *****\x1b[0m\n", file, line, err);
|
||||
printf("\n%s\n", buf);
|
||||
fprintf(stderr, "\n%s\n", buf);
|
||||
failure_strings.push_back(buf);
|
||||
++_g_test_failures;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,10 @@ TORRENT_TEST(rename_file)
|
|||
st.rename_file(0, "/tmp/a");
|
||||
TEST_EQUAL(st.file_path(0, "."), "/tmp/a");
|
||||
#endif
|
||||
|
||||
st.rename_file(0, combine_path("test__", "a"));
|
||||
TEST_EQUAL(st.file_path(0, "."), combine_path(".", combine_path("test__"
|
||||
, "a")));
|
||||
}
|
||||
|
||||
TORRENT_TEST(set_name)
|
||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "test.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
#include "test_utils.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "libtorrent/storage.hpp"
|
||||
#include "libtorrent/file_pool.hpp"
|
||||
|
@ -749,11 +750,7 @@ TORRENT_TEST(rename_file)
|
|||
& ~(alert::performance_warning
|
||||
| alert::stats_notification);
|
||||
|
||||
settings_pack pack;
|
||||
pack.set_bool(settings_pack::enable_lsd, false);
|
||||
pack.set_bool(settings_pack::enable_natpmp, false);
|
||||
pack.set_bool(settings_pack::enable_upnp, false);
|
||||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
settings_pack pack = settings();
|
||||
pack.set_int(settings_pack::alert_mask, mask);
|
||||
pack.set_bool(settings_pack::disable_hash_checks, true);
|
||||
lt::session ses(pack);
|
||||
|
@ -777,14 +774,14 @@ TORRENT_TEST(rename_file)
|
|||
for (int i = 0; i < info->num_files(); ++i)
|
||||
{
|
||||
std::string name = fs.file_path(i);
|
||||
h.rename_file(i, "__" + name);
|
||||
h.rename_file(i, "temp_storage__" + name.substr(12));
|
||||
}
|
||||
|
||||
// wait fir the files to have been renamed
|
||||
alert const* fra = wait_for_alert(ses, file_renamed_alert::alert_type, "ses", info->num_files());
|
||||
TEST_CHECK(fra);
|
||||
|
||||
TEST_CHECK(exists("__" + info->name()));
|
||||
TEST_CHECK(exists(info->name() + "__"));
|
||||
|
||||
h.save_resume_data();
|
||||
alert const* ra = wait_for_alert(ses, save_resume_data_alert::alert_type);
|
||||
|
@ -797,7 +794,7 @@ TORRENT_TEST(rename_file)
|
|||
entry::list_type files = resume.dict().find("mapped_files")->second.list();
|
||||
for (entry::list_type::iterator i = files.begin(); i != files.end(); ++i)
|
||||
{
|
||||
TEST_CHECK(i->string().substr(0, 2) == "__");
|
||||
TEST_EQUAL(i->string().substr(0, 14), "temp_storage__");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue