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)
|
||||
+ ": " + a->msg());
|
||||
}
|
||||
else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get()))
|
||||
{
|
||||
events.push_back(now + ": tracker message: " + p->msg());
|
||||
}
|
||||
else
|
||||
{
|
||||
events.push_back(now + ": " + a->msg());
|
||||
|
|
|
@ -98,6 +98,12 @@ namespace libtorrent
|
|||
struct eh_initializer {};
|
||||
#endif
|
||||
struct session_impl;
|
||||
|
||||
struct filesystem_init
|
||||
{
|
||||
filesystem_init();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
class TORRENT_EXPORT session_proxy
|
||||
|
@ -215,14 +221,18 @@ namespace libtorrent
|
|||
std::auto_ptr<alert> pop_alert();
|
||||
void set_severity_level(alert::severity_t s);
|
||||
|
||||
// Resource management used for global limits.
|
||||
resource_request m_ul_bandwidth_quota;
|
||||
// Resource management used for global limits.
|
||||
resource_request m_ul_bandwidth_quota;
|
||||
resource_request m_dl_bandwidth_quota;
|
||||
resource_request m_uploads_quota;
|
||||
resource_request m_connections_quota;
|
||||
|
||||
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
|
||||
// and the working thread
|
||||
boost::shared_ptr<aux::session_impl> m_impl;
|
||||
|
|
|
@ -116,7 +116,10 @@ namespace libtorrent
|
|||
if (newline == pos)
|
||||
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;
|
||||
int incoming = (int)std::distance(pos, newline);
|
||||
m_recv_pos += incoming;
|
||||
|
|
|
@ -83,6 +83,16 @@ using libtorrent::aux::session_impl;
|
|||
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(
|
||||
fingerprint const& id
|
||||
, std::pair<int, int> listen_port_range
|
||||
|
@ -90,9 +100,6 @@ namespace libtorrent
|
|||
: m_impl(new session_impl(listen_port_range, id, listen_interface))
|
||||
{
|
||||
// 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 < listen_port_range.second);
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -1631,8 +1631,27 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
assert(m_storage.get());
|
||||
bool done = m_storage->check_fastresume(data, m_have_pieces, m_num_pieces
|
||||
, m_compact_mode);
|
||||
bool done = true;
|
||||
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
|
||||
m_initial_done = boost::get<0>(bytes_done());
|
||||
#endif
|
||||
|
@ -1644,7 +1663,27 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
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
|
||||
m_initial_done = boost::get<0>(bytes_done());
|
||||
|
|
Loading…
Reference in New Issue