mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-18 07:06:18 +00:00
Deletes torrents in the session directory when they are removed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@293 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -20,13 +20,14 @@ DownloadList::insert(std::istream* str) {
|
|||||||
return itr;
|
return itr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
DownloadList::iterator
|
||||||
DownloadList::erase(iterator itr) {
|
DownloadList::erase(iterator itr) {
|
||||||
(*itr)->release_download();
|
(*itr)->release_download();
|
||||||
|
|
||||||
torrent::download_remove((*itr)->get_hash());
|
torrent::download_remove((*itr)->get_hash());
|
||||||
delete *itr;
|
delete *itr;
|
||||||
Base::erase(itr);
|
|
||||||
|
return Base::erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
~DownloadList() { clear(); }
|
~DownloadList() { clear(); }
|
||||||
|
|
||||||
iterator insert(std::istream* str);
|
iterator insert(std::istream* str);
|
||||||
void erase(iterator itr);
|
iterator erase(iterator itr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <unistd.h>
|
||||||
#include <torrent/bencode.h>
|
#include <torrent/bencode.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
|
|
||||||
@@ -30,6 +31,9 @@ DownloadStore::disable() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadStore::save(Download* d) {
|
DownloadStore::save(Download* d) {
|
||||||
|
if (!is_active())
|
||||||
|
return;
|
||||||
|
|
||||||
std::fstream f(create_filename(d).c_str(), std::ios::out | std::ios::trunc);
|
std::fstream f(create_filename(d).c_str(), std::ios::out | std::ios::trunc);
|
||||||
|
|
||||||
if (!f.is_open())
|
if (!f.is_open())
|
||||||
@@ -43,6 +47,10 @@ DownloadStore::save(Download* d) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadStore::remove(Download* d) {
|
DownloadStore::remove(Download* d) {
|
||||||
|
if (!is_active())
|
||||||
|
return;
|
||||||
|
|
||||||
|
unlink(create_filename(d).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
|||||||
+6
-4
@@ -39,15 +39,17 @@ Manager::insert(const std::string& uri) {
|
|||||||
create_http(uri);
|
create_http(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Manager::iterator
|
||||||
Manager::erase(DownloadList::iterator itr) {
|
Manager::erase(DownloadList::iterator itr) {
|
||||||
if ((*itr)->get_download().is_active())
|
if ((*itr)->get_download().is_active())
|
||||||
throw std::logic_error("core::Manager::erase(...) called on an active download");
|
throw std::logic_error("core::Manager::erase(...) called on an active download");
|
||||||
|
|
||||||
if ((*itr)->get_download().is_open())
|
if (!(*itr)->get_download().is_open())
|
||||||
(*itr)->close();
|
throw std::logic_error("core::Manager::erase(...) called on an closed download");
|
||||||
|
|
||||||
m_downloadList.erase(itr);
|
m_downloadStore.remove(*itr);
|
||||||
|
|
||||||
|
return m_downloadList.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+2
-1
@@ -11,6 +11,7 @@ namespace core {
|
|||||||
|
|
||||||
class Manager {
|
class Manager {
|
||||||
public:
|
public:
|
||||||
|
typedef DownloadList::iterator iterator;
|
||||||
typedef sigc::slot1<void, DownloadList::iterator> SlotReady;
|
typedef sigc::slot1<void, DownloadList::iterator> SlotReady;
|
||||||
typedef sigc::slot0<void> SlotFailed;
|
typedef sigc::slot0<void> SlotFailed;
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public:
|
|||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
void insert(const std::string& uri);
|
void insert(const std::string& uri);
|
||||||
void erase(DownloadList::iterator itr);
|
iterator erase(DownloadList::iterator itr);
|
||||||
|
|
||||||
void start(Download* d);
|
void start(Download* d);
|
||||||
void stop(Download* d);
|
void stop(Download* d);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ WindowPeerInfo::redraw() {
|
|||||||
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
m_canvas->print(0, y++, "Hash: %s", utils::escape_string(m_download->get_download().get_hash()).c_str());
|
m_canvas->print(0, y++, "Hash: %s", utils::string_to_hex(m_download->get_download().get_hash()).c_str());
|
||||||
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
|
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
|
||||||
m_download->get_download().get_chunks_done(),
|
m_download->get_download().get_chunks_done(),
|
||||||
m_download->get_download().get_chunks_total(),
|
m_download->get_download().get_chunks_total(),
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ DownloadList::receive_stop_download() {
|
|||||||
if ((*m_focus)->get_download().is_active())
|
if ((*m_focus)->get_download().is_active())
|
||||||
m_control->get_core().stop(*m_focus);
|
m_control->get_core().stop(*m_focus);
|
||||||
else
|
else
|
||||||
m_control->get_core().erase(m_focus);
|
m_focus = m_control->get_core().erase(m_focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user