forked from premiere/premiere-libtorrent
fixed utf-8 verification bug and filename collision resolver
This commit is contained in:
parent
3599b130c0
commit
7b53dd0491
|
@ -14,6 +14,8 @@
|
|||
* fix uTP edge case where udp socket buffer fills up
|
||||
* fix nagle implementation in uTP
|
||||
|
||||
* fix bug filename collision resolver
|
||||
* fix bug in filename utf-8 verification
|
||||
* make need_save_resume() a bit more robust
|
||||
* fixed sparse flag manipulation on windows
|
||||
* fixed streaming piece picking issue
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// valid 4-byte utf-8 character
|
||||
if ((i[0] & 0xf0) == 0xe0
|
||||
if ((i[0] & 0xf8) == 0xf0
|
||||
&& (i[1] & 0xc0) == 0x80
|
||||
&& (i[2] & 0xc0) == 0x80
|
||||
&& (i[3] & 0xc0) == 0x80)
|
||||
|
@ -354,6 +354,13 @@ namespace libtorrent
|
|||
{
|
||||
if (list.type() != lazy_entry::list_t) return false;
|
||||
target.reserve(list.list_size());
|
||||
|
||||
// TODO: 1 this logic should be a separate step
|
||||
// done once the torrent is loaded, and the original
|
||||
// filenames should be preserved!
|
||||
int cnt = 0;
|
||||
std::set<std::string, string_less_no_case> files;
|
||||
|
||||
for (int i = 0, end(list.list_size()); i < end; ++i)
|
||||
{
|
||||
lazy_entry const* file_hash = 0;
|
||||
|
@ -364,20 +371,13 @@ namespace libtorrent
|
|||
, &file_hash, &fee, &mtime))
|
||||
return false;
|
||||
|
||||
// TODO: 1 this logic should be a separate step
|
||||
// done once the torrent is loaded, and the original
|
||||
// filenames should be preserved!
|
||||
int cnt = 0;
|
||||
std::set<std::string, string_less_no_case> files;
|
||||
|
||||
// as long as this file already exists
|
||||
// increase the counter
|
||||
fprintf(stderr, "adding file: %s\n", e.path.c_str());
|
||||
while (!files.insert(e.path).second)
|
||||
{
|
||||
++cnt;
|
||||
char suffix[50];
|
||||
snprintf(suffix, sizeof(suffix), ".%d%s", cnt, extension(e.path).c_str());
|
||||
snprintf(suffix, sizeof(suffix), "%d%s", cnt, extension(e.path).c_str());
|
||||
replace_extension(e.path, suffix);
|
||||
}
|
||||
target.add_file(e, file_hash ? file_hash->string_ptr() + info_ptr_diff : 0);
|
||||
|
|
|
@ -1392,6 +1392,12 @@ int test_main()
|
|||
comparison.resize(TORRENT_MAX_PATH);
|
||||
TEST_EQUAL(test, comparison);
|
||||
|
||||
|
||||
// replace_extension
|
||||
test = "foo.bar";
|
||||
replace_extension(test, "txt");
|
||||
TEST_EQUAL(test, "foo.txt");
|
||||
|
||||
// file class
|
||||
file f;
|
||||
#if TORRENT_USE_UNC_PATHS || !defined WIN32
|
||||
|
|
Loading…
Reference in New Issue