add filename to web seed urls that don't have one

This commit is contained in:
Arvid Norberg 2009-08-18 22:00:52 +00:00
parent 0ba85d70e2
commit ab1add0da9
2 changed files with 16 additions and 6 deletions

View File

@ -66,6 +66,8 @@
* improved support for sparse files on windows
* added ability to give seeding torrents preference to active slots
* fixed to add filename on web seed urls that lack it
release 0.14.5
* fixed bug when handling malformed webseed urls and an http proxy

View File

@ -170,12 +170,20 @@ namespace libtorrent
bool single_file_request = t->torrent_file().num_files() == 1;
// handle incorrect .torrent files which are multi-file
// but have web seeds not ending with a slash
if (!single_file_request && (m_path.empty() || m_path[m_path.size() - 1] != '/'))
m_path += "/";
if (!single_file_request && (m_url.empty() || m_url[m_url.size() - 1] != '/'))
m_url += "/";
if (!single_file_request)
{
// handle incorrect .torrent files which are multi-file
// but have web seeds not ending with a slash
if (m_path.empty() || m_path[m_path.size() - 1] != '/') m_path += "/";
if (m_url.empty() || m_url[m_url.size() - 1] != '/') m_url += "/";
}
else
{
// handle .torrent files that don't include the filename in the url
if (m_path.empty()) m_path += "/" + t->torrent_file().name();
else if (m_path[m_path.size() - 1] == '/') m_path += t->torrent_file().name();
if (!m_url.empty() && m_url[m_url.size() - 1] == '/') m_url += t->torrent_file().name();
}
torrent_info const& info = t->torrent_file();