fixed so that both session constructors initializes boost.filesystem. Fixed the case where the file check throws exceptions, the torrent is no longer removed, but paused
This commit is contained in:
parent
a78ef76592
commit
d58c6d2e31
|
@ -789,6 +789,10 @@ int main(int ac, char* av[])
|
||||||
events.push_back(now + ": " + identify_client(p->pid)
|
events.push_back(now + ": " + identify_client(p->pid)
|
||||||
+ ": " + a->msg());
|
+ ": " + a->msg());
|
||||||
}
|
}
|
||||||
|
else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get()))
|
||||||
|
{
|
||||||
|
events.push_back(now + ": tracker message: " + p->msg());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
events.push_back(now + ": " + a->msg());
|
events.push_back(now + ": " + a->msg());
|
||||||
|
|
|
@ -98,6 +98,12 @@ namespace libtorrent
|
||||||
struct eh_initializer {};
|
struct eh_initializer {};
|
||||||
#endif
|
#endif
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
|
|
||||||
|
struct filesystem_init
|
||||||
|
{
|
||||||
|
filesystem_init();
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TORRENT_EXPORT session_proxy
|
class TORRENT_EXPORT session_proxy
|
||||||
|
@ -215,14 +221,18 @@ namespace libtorrent
|
||||||
std::auto_ptr<alert> pop_alert();
|
std::auto_ptr<alert> pop_alert();
|
||||||
void set_severity_level(alert::severity_t s);
|
void set_severity_level(alert::severity_t s);
|
||||||
|
|
||||||
// Resource management used for global limits.
|
// Resource management used for global limits.
|
||||||
resource_request m_ul_bandwidth_quota;
|
resource_request m_ul_bandwidth_quota;
|
||||||
resource_request m_dl_bandwidth_quota;
|
resource_request m_dl_bandwidth_quota;
|
||||||
resource_request m_uploads_quota;
|
resource_request m_uploads_quota;
|
||||||
resource_request m_connections_quota;
|
resource_request m_connections_quota;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// just a way to initialize boost.filesystem
|
||||||
|
// before the session_impl is created
|
||||||
|
aux::filesystem_init m_dummy;
|
||||||
|
|
||||||
// data shared between the main thread
|
// data shared between the main thread
|
||||||
// and the working thread
|
// and the working thread
|
||||||
boost::shared_ptr<aux::session_impl> m_impl;
|
boost::shared_ptr<aux::session_impl> m_impl;
|
||||||
|
|
|
@ -116,7 +116,10 @@ namespace libtorrent
|
||||||
if (newline == pos)
|
if (newline == pos)
|
||||||
throw std::runtime_error("unexpected newline in HTTP response");
|
throw std::runtime_error("unexpected newline in HTTP response");
|
||||||
|
|
||||||
std::istringstream line(std::string(pos, newline - 1));
|
char const* line_end = newline;
|
||||||
|
if (pos != line_end && *(line_end - 1) == '\r') --line_end;
|
||||||
|
|
||||||
|
std::istringstream line(std::string(pos, line_end));
|
||||||
++newline;
|
++newline;
|
||||||
int incoming = (int)std::distance(pos, newline);
|
int incoming = (int)std::distance(pos, newline);
|
||||||
m_recv_pos += incoming;
|
m_recv_pos += incoming;
|
||||||
|
|
|
@ -83,6 +83,16 @@ using libtorrent::aux::session_impl;
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace aux
|
||||||
|
{
|
||||||
|
filesystem_init::filesystem_init()
|
||||||
|
{
|
||||||
|
using namespace boost::filesystem;
|
||||||
|
if (path::default_name_check_writable())
|
||||||
|
path::default_name_check(no_check);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session::session(
|
session::session(
|
||||||
fingerprint const& id
|
fingerprint const& id
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
|
@ -90,9 +100,6 @@ namespace libtorrent
|
||||||
: m_impl(new session_impl(listen_port_range, id, listen_interface))
|
: m_impl(new session_impl(listen_port_range, id, listen_interface))
|
||||||
{
|
{
|
||||||
// turn off the filename checking in boost.filesystem
|
// turn off the filename checking in boost.filesystem
|
||||||
using namespace boost::filesystem;
|
|
||||||
if (path::default_name_check_writable())
|
|
||||||
path::default_name_check(no_check);
|
|
||||||
assert(listen_port_range.first > 0);
|
assert(listen_port_range.first > 0);
|
||||||
assert(listen_port_range.first < listen_port_range.second);
|
assert(listen_port_range.first < listen_port_range.second);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -1631,8 +1631,27 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m_storage.get());
|
assert(m_storage.get());
|
||||||
bool done = m_storage->check_fastresume(data, m_have_pieces, m_num_pieces
|
bool done = true;
|
||||||
, m_compact_mode);
|
try
|
||||||
|
{
|
||||||
|
done = m_storage->check_fastresume(data, m_have_pieces, m_num_pieces
|
||||||
|
, m_compact_mode);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
// probably means file permission failure or invalid filename
|
||||||
|
std::fill(m_have_pieces.begin(), m_have_pieces.end(), false);
|
||||||
|
m_num_pieces = 0;
|
||||||
|
|
||||||
|
if (m_ses.m_alerts.should_post(alert::fatal))
|
||||||
|
{
|
||||||
|
m_ses.m_alerts.post_alert(
|
||||||
|
file_error_alert(
|
||||||
|
get_handle()
|
||||||
|
, e.what()));
|
||||||
|
}
|
||||||
|
pause();
|
||||||
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
m_initial_done = boost::get<0>(bytes_done());
|
m_initial_done = boost::get<0>(bytes_done());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1644,7 +1663,27 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
assert(m_storage.get());
|
assert(m_storage.get());
|
||||||
std::pair<bool, float> progress = m_storage->check_files(m_have_pieces, m_num_pieces);
|
|
||||||
|
std::pair<bool, float> progress(true, 1.f);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
progress = m_storage->check_files(m_have_pieces, m_num_pieces);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
// probably means file permission failure or invalid filename
|
||||||
|
std::fill(m_have_pieces.begin(), m_have_pieces.end(), false);
|
||||||
|
m_num_pieces = 0;
|
||||||
|
|
||||||
|
if (m_ses.m_alerts.should_post(alert::fatal))
|
||||||
|
{
|
||||||
|
m_ses.m_alerts.post_alert(
|
||||||
|
file_error_alert(
|
||||||
|
get_handle()
|
||||||
|
, e.what()));
|
||||||
|
}
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
m_initial_done = boost::get<0>(bytes_done());
|
m_initial_done = boost::get<0>(bytes_done());
|
||||||
|
|
Loading…
Reference in New Issue