mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-13 05:32:31 +00:00
* Unlink the tied file when a torrent is erased.
* Remove torrents that are already tied from the expanded paths. * Move the loop counter to Control. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@618 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+3
-1
@@ -61,7 +61,9 @@ Control::Control() :
|
||||
m_inputStdin(new input::InputEvent(STDIN_FILENO)),
|
||||
|
||||
m_commandScheduler(new CommandScheduler()),
|
||||
m_optionHandler(new OptionHandler()) {
|
||||
m_optionHandler(new OptionHandler()),
|
||||
|
||||
m_tick(0) {
|
||||
|
||||
m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed));
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#ifndef RTORRENT_CONTROL_H
|
||||
#define RTORRENT_CONTROL_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "globals.h"
|
||||
@@ -83,6 +84,9 @@ public:
|
||||
CommandScheduler* command_scheduler() { return m_commandScheduler; }
|
||||
OptionHandler* option_handler() { return m_optionHandler; }
|
||||
|
||||
uint64_t tick() const { return m_tick; }
|
||||
void inc_tick() { m_tick++; }
|
||||
|
||||
private:
|
||||
Control(const Control&);
|
||||
void operator = (const Control&);
|
||||
@@ -98,6 +102,8 @@ private:
|
||||
CommandScheduler* m_commandScheduler;
|
||||
OptionHandler* m_optionHandler;
|
||||
|
||||
uint64_t m_tick;
|
||||
|
||||
rak::priority_item m_taskShutdown;
|
||||
};
|
||||
|
||||
|
||||
+23
-1
@@ -74,6 +74,15 @@ connect_signal_storage_log(Download* d, torrent::Download::SlotString s) {
|
||||
d->get_download().signal_storage_error(s);
|
||||
}
|
||||
|
||||
// Hmm... find some better place for all this.
|
||||
static void
|
||||
delete_tied(Download* d) {
|
||||
// This should be configurable, need to wait for the variable
|
||||
// thingie to be implemented.
|
||||
if (!d->tied_to_file().empty())
|
||||
::unlink(d->tied_to_file().c_str());
|
||||
}
|
||||
|
||||
Manager::Manager() :
|
||||
m_pollManager(NULL),
|
||||
m_portRandom(false),
|
||||
@@ -112,6 +121,7 @@ Manager::initialize_second() {
|
||||
|
||||
m_downloadList.slot_map_erase()["1_hash_queue_remove"] = sigc::mem_fun(m_hashQueue, &HashQueue::remove);
|
||||
m_downloadList.slot_map_erase()["1_store_remove"] = sigc::mem_fun(m_downloadStore, &DownloadStore::remove);
|
||||
m_downloadList.slot_map_erase()["1_delete_tied"] = sigc::ptr_fun(&delete_tied);
|
||||
|
||||
m_downloadList.slot_map_open()["1_download_open"] = sigc::mem_fun(&Download::call<void, &torrent::Download::open>);
|
||||
|
||||
@@ -350,8 +360,12 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
if (r.pattern().empty())
|
||||
continue;
|
||||
|
||||
// Special case for ".."?
|
||||
|
||||
for (std::vector<utils::Directory>::iterator itr = currentCache.begin(); itr != currentCache.end(); ++itr) {
|
||||
itr->update(false);
|
||||
// Only include filenames starting with '.' if the pattern
|
||||
// starts with the same.
|
||||
itr->update(r.pattern()[0] != '.');
|
||||
itr->erase(std::remove_if(itr->begin(), itr->end(), std::not1(r)), itr->end());
|
||||
|
||||
std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), std::bind1st(std::plus<std::string>(), itr->get_path() + "/"));
|
||||
@@ -371,6 +385,14 @@ Manager::try_create_download_expand(const std::string& uri, bool start, bool pri
|
||||
|
||||
path_expand(&paths, uri);
|
||||
|
||||
if (tied)
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); )
|
||||
if (std::find_if(m_downloadList.begin(), m_downloadList.end(),
|
||||
rak::equal(*itr, std::mem_fun(&Download::tied_to_file))) != m_downloadList.end())
|
||||
itr = paths.erase(itr);
|
||||
else
|
||||
itr++;
|
||||
|
||||
if (!paths.empty())
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); ++itr)
|
||||
try_create_download(*itr, start, printLog, tied);
|
||||
|
||||
@@ -152,7 +152,7 @@ Manager::schedule_update() {
|
||||
if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) {
|
||||
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
|
||||
rak::priority_queue_insert(&taskScheduler, &m_taskUpdate,
|
||||
std::max(m_scheduler.top()->time(), m_timeLastUpdate + 100000));
|
||||
std::max(m_scheduler.top()->time(), m_timeLastUpdate + 50000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,19 +39,16 @@
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "canvas.h"
|
||||
#include "window_statusbar.h"
|
||||
|
||||
extern uint32_t countTicks;
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowStatusbar::WindowStatusbar(core::Manager* c) :
|
||||
WindowStatusbar::WindowStatusbar(Control* c) :
|
||||
Window(new Canvas, false, 1),
|
||||
m_counter(0),
|
||||
m_core(c) {
|
||||
m_lastTick(0),
|
||||
m_control(c) {
|
||||
}
|
||||
|
||||
void
|
||||
@@ -86,7 +83,7 @@ WindowStatusbar::redraw() {
|
||||
pos = snprintf(buf, 128, "[U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||
#else
|
||||
pos = snprintf(buf, 128, "%i [U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||
countTicks,
|
||||
(int)(m_control->tick() - m_lastTick),
|
||||
#endif
|
||||
torrent::currently_unchoked(),
|
||||
torrent::max_unchoked(),
|
||||
@@ -96,9 +93,9 @@ WindowStatusbar::redraw() {
|
||||
torrent::open_files(),
|
||||
torrent::max_open_files());
|
||||
|
||||
countTicks = 0;
|
||||
|
||||
m_canvas->print(m_canvas->get_width() - pos, 0, "%s", buf);
|
||||
|
||||
m_lastTick = m_control->tick();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,23 +37,23 @@
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_STATUSBAR_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_STATUSBAR_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
namespace core {
|
||||
class Manager;
|
||||
}
|
||||
class Control;
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowStatusbar : public Window {
|
||||
public:
|
||||
WindowStatusbar(core::Manager* c);
|
||||
WindowStatusbar(Control* c);
|
||||
|
||||
virtual void redraw();
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
int m_counter;
|
||||
core::Manager* m_core;
|
||||
uint64_t m_lastTick;
|
||||
Control* m_control;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -74,8 +74,6 @@
|
||||
#include "command_scheduler.h"
|
||||
#include "command_scheduler_item.h"
|
||||
|
||||
uint32_t countTicks = 0;
|
||||
|
||||
void do_panic(int signum);
|
||||
void print_help();
|
||||
|
||||
@@ -202,7 +200,7 @@ main(int argc, char** argv) {
|
||||
control.display()->adjust_layout();
|
||||
|
||||
while (!control.is_shutdown_completed()) {
|
||||
countTicks++;
|
||||
control.inc_tick();
|
||||
|
||||
cachedTime = rak::timer::current();
|
||||
rak::priority_queue_perform(&taskScheduler, cachedTime);
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ Root::init(Control* c) {
|
||||
m_control = c;
|
||||
setup_keys();
|
||||
|
||||
m_windowStatusbar = new WStatusbar(m_control->core());
|
||||
m_windowStatusbar = new WStatusbar(m_control);
|
||||
m_downloadList = new DownloadList(m_control);
|
||||
|
||||
m_control->display()->push_back(m_windowStatusbar);
|
||||
|
||||
Reference in New Issue
Block a user