mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
* Keep a cache listing all, including failed, torrent loads and the
mtimes of those files. This is used to ensure that e.g. the watch dir does not try to load bad/duplicate torrents, in addition to optimizing the pruning of those already loaded. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1024 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -61,6 +61,14 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
bool
|
||||
is_network_uri(const std::string& uri) {
|
||||
return
|
||||
std::strncmp(uri.c_str(), "http://", 7) == 0 ||
|
||||
std::strncmp(uri.c_str(), "https://", 8) == 0 ||
|
||||
std::strncmp(uri.c_str(), "ftp://", 6) == 0;
|
||||
}
|
||||
|
||||
DownloadFactory::DownloadFactory(Manager* m) :
|
||||
m_manager(m),
|
||||
m_stream(NULL),
|
||||
@@ -69,7 +77,8 @@ DownloadFactory::DownloadFactory(Manager* m) :
|
||||
|
||||
m_session(false),
|
||||
m_start(false),
|
||||
m_printLog(true) {
|
||||
m_printLog(true),
|
||||
m_isFile(false) {
|
||||
|
||||
m_taskLoad.set_slot(rak::mem_fn(this, &DownloadFactory::receive_load));
|
||||
m_taskCommit.set_slot(rak::mem_fn(this, &DownloadFactory::receive_commit));
|
||||
@@ -114,9 +123,7 @@ DownloadFactory::receive_load() {
|
||||
if (m_stream)
|
||||
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
|
||||
|
||||
if (std::strncmp(m_uri.c_str(), "http://", 7) == 0 ||
|
||||
std::strncmp(m_uri.c_str(), "https://", 8) == 0 ||
|
||||
std::strncmp(m_uri.c_str(), "ftp://", 6) == 0) {
|
||||
if (is_network_uri(m_uri)) {
|
||||
// Http handling here.
|
||||
m_stream = new std::stringstream;
|
||||
HttpQueue::iterator itr = m_manager->http_queue()->insert(m_uri, m_stream);
|
||||
@@ -130,10 +137,14 @@ DownloadFactory::receive_load() {
|
||||
std::fstream* stream = new std::fstream(rak::path_expand(m_uri).c_str(), std::ios::in | std::ios::binary);
|
||||
m_stream = stream;
|
||||
|
||||
if (stream->is_open())
|
||||
receive_loaded();
|
||||
else
|
||||
receive_failed("Could not open file");
|
||||
// Since FileStatusCache checks file stats, it will automatically
|
||||
// cull away invalid paths.
|
||||
m_isFile = true;
|
||||
|
||||
if (!stream->is_open())
|
||||
return receive_failed("Could not open file");
|
||||
|
||||
receive_loaded();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user