mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-11 02:48:39 +00:00
lt sync 2642
This commit is contained in:
parent
6f7e814e76
commit
892e642502
4 changed files with 30 additions and 3 deletions
|
@ -46,6 +46,7 @@ namespace libtorrent
|
||||||
struct torrent_handle;
|
struct torrent_handle;
|
||||||
|
|
||||||
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
|
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
|
||||||
|
std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info);
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 0.14
|
// deprecated in 0.14
|
||||||
|
|
|
@ -69,6 +69,26 @@ namespace libtorrent
|
||||||
return ret.str();
|
return ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string make_magnet_uri(torrent_info const& info)
|
||||||
|
{
|
||||||
|
std::stringstream ret;
|
||||||
|
if (!info.is_valid()) return ret.str();
|
||||||
|
|
||||||
|
std::string name = info.name();
|
||||||
|
|
||||||
|
ret << "magnet:?xt=urn:btih:" << base32encode(
|
||||||
|
std::string((char*)info.info_hash().begin(), 20));
|
||||||
|
if (!name.empty())
|
||||||
|
ret << "&dn=" << escape_string(name.c_str(), name.length());
|
||||||
|
std::vector<announce_entry> const& tr = info.trackers();
|
||||||
|
if (!tr.empty())
|
||||||
|
{
|
||||||
|
ret << "&tr=" << escape_string(tr[0].url.c_str()
|
||||||
|
, tr[0].url.length());
|
||||||
|
}
|
||||||
|
return ret.str();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
||||||
, fs::path const& save_path
|
, fs::path const& save_path
|
||||||
|
|
|
@ -1706,9 +1706,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->alerts().should_post<file_error_alert>())
|
if (t->alerts().should_post<file_error_alert>())
|
||||||
{
|
|
||||||
t->alerts().post_alert(file_error_alert(j.error_file, t->get_handle(), j.str));
|
t->alerts().post_alert(file_error_alert(j.error_file, t->get_handle(), j.str));
|
||||||
}
|
t->set_error(j.str);
|
||||||
t->pause();
|
t->pause();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,11 @@ namespace libtorrent
|
||||||
|
|
||||||
void torrent::start()
|
void torrent::start()
|
||||||
{
|
{
|
||||||
|
// we need to start announcing since we don't have any
|
||||||
|
// metadata. To receive peers to ask for it.
|
||||||
if (m_torrent_file->is_valid()) init();
|
if (m_torrent_file->is_valid()) init();
|
||||||
|
else if (!m_trackers.empty()) start_announcing();
|
||||||
|
|
||||||
if (m_abort) return;
|
if (m_abort) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3919,7 +3923,10 @@ namespace libtorrent
|
||||||
void torrent::start_announcing()
|
void torrent::start_announcing()
|
||||||
{
|
{
|
||||||
if (is_paused()) return;
|
if (is_paused()) return;
|
||||||
if (!m_files_checked) return;
|
// if we don't have metadata, we need to announce
|
||||||
|
// before checking files, to get peers to
|
||||||
|
// request the metadata from
|
||||||
|
if (!m_files_checked && valid_metadata()) return;
|
||||||
if (m_announcing) return;
|
if (m_announcing) return;
|
||||||
|
|
||||||
m_announcing = true;
|
m_announcing = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue