mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-04 21:29:21 +00:00
Compare commits
4 Commits
83a5e7687b
...
8e23ba8b17
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e23ba8b17 | |||
| e656801cfa | |||
| 9f6fd7994e | |||
| bb77aa644c |
@@ -28,9 +28,10 @@ cmd_scheduler_simple_removed(core::Download* download) {
|
||||
control->core()->download_list()->pause(download);
|
||||
|
||||
core::View* viewActive = *control->view_manager()->find("active");
|
||||
unsigned int numActive = viewActive->size_visible();
|
||||
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
|
||||
|
||||
if ((int64_t)viewActive->size_visible() >= maxActive)
|
||||
if ((int64_t)numActive >= maxActive)
|
||||
return torrent::Object();
|
||||
|
||||
// The 'started' view contains all the views we may choose amongst.
|
||||
@@ -41,6 +42,9 @@ cmd_scheduler_simple_removed(core::Download* download) {
|
||||
continue;
|
||||
|
||||
control->core()->download_list()->resume(*itr);
|
||||
|
||||
if ((int64_t)++numActive >= maxActive)
|
||||
break;
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
|
||||
@@ -100,7 +100,7 @@ PathInput::receive_do_complete() {
|
||||
entry.s_name += '/';
|
||||
}
|
||||
|
||||
range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
|
||||
range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos() - dirEnd));
|
||||
|
||||
if (r.first == r.second)
|
||||
return; // Show some nice colors here.
|
||||
|
||||
+4
-2
@@ -492,7 +492,8 @@ main(int argc, char** argv) {
|
||||
control->cleanup();
|
||||
|
||||
} catch (torrent::internal_error& e) {
|
||||
control->cleanup_exception();
|
||||
if (control != nullptr)
|
||||
control->cleanup_exception();
|
||||
|
||||
std::cout << "rtorrent: caught torrent::internal_error: "
|
||||
<< e.what() << std::endl
|
||||
@@ -505,7 +506,8 @@ main(int argc, char** argv) {
|
||||
return -1;
|
||||
|
||||
} catch (std::exception& e) {
|
||||
control->cleanup_exception();
|
||||
if (control != nullptr)
|
||||
control->cleanup_exception();
|
||||
|
||||
std::cout << "rtorrent: caught" << typeid(e).name() << " : " << e.what() << std::endl;
|
||||
|
||||
|
||||
@@ -394,6 +394,10 @@ execute_lua(LuaEngine* engine, rpc::target_type target_type, torrent::Object con
|
||||
switch (raw_args.type()) {
|
||||
case torrent::Object::TYPE_LIST: {
|
||||
const torrent::Object::list_type& args = raw_args.as_list();
|
||||
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
if (flags & LuaEngine::flag_string) {
|
||||
check_lua_status(l_state, luaL_loadstring(l_state, args.begin()->as_string().c_str()));
|
||||
} else {
|
||||
|
||||
@@ -69,6 +69,8 @@ rtorrent_Test_Src_SOURCES = $(rtorrent_Test_Common) \
|
||||
src/test_command_string.h \
|
||||
src/test_command_throttle.cc \
|
||||
src/test_command_throttle.h \
|
||||
src/test_input_path_input.cc \
|
||||
src/test_input_path_input.h \
|
||||
src/test_session_commit.cc \
|
||||
src/test_session_commit.h \
|
||||
src/test_session_storer.cc \
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "test/src/test_input_path_input.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "input/path_input.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestInputPathInput);
|
||||
|
||||
void
|
||||
TestInputPathInput::setUp() {
|
||||
test_fixture::setUp();
|
||||
|
||||
char temp_dir[] = "/tmp/rtorrent_test_path_input_XXXXXX";
|
||||
|
||||
CPPUNIT_ASSERT(mkdtemp(temp_dir) != nullptr);
|
||||
|
||||
m_temp_dir = temp_dir;
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, mkdir((m_temp_dir + "/alpha").c_str(), 0755));
|
||||
CPPUNIT_ASSERT_EQUAL(0, mkdir((m_temp_dir + "/alpha/beta").c_str(), 0755));
|
||||
}
|
||||
|
||||
void
|
||||
TestInputPathInput::tearDown() {
|
||||
rmdir((m_temp_dir + "/alpha/beta").c_str());
|
||||
rmdir((m_temp_dir + "/alpha").c_str());
|
||||
rmdir(m_temp_dir.c_str());
|
||||
|
||||
test_fixture::tearDown();
|
||||
}
|
||||
|
||||
// Tab at the end of the line completes the trailing component.
|
||||
void
|
||||
TestInputPathInput::test_complete_at_end() {
|
||||
input::PathInput input;
|
||||
|
||||
input.str() = m_temp_dir + "/al";
|
||||
input.set_pos(input.str().size());
|
||||
|
||||
CPPUNIT_ASSERT(input.pressed('\t'));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(m_temp_dir + "/alpha/", input.str());
|
||||
CPPUNIT_ASSERT_EQUAL(input.str().size(), input.get_pos());
|
||||
}
|
||||
|
||||
// The same completion with the cursor left inside the line. Only the text up to
|
||||
// the cursor selects the entry, and the rest of the line is discarded.
|
||||
void
|
||||
TestInputPathInput::test_complete_mid_line() {
|
||||
input::PathInput input;
|
||||
|
||||
input.str() = m_temp_dir + "/alZZZ";
|
||||
input.set_pos(m_temp_dir.size() + 3);
|
||||
|
||||
CPPUNIT_ASSERT(input.pressed('\t'));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(m_temp_dir + "/alpha/", input.str());
|
||||
CPPUNIT_ASSERT_EQUAL(input.str().size(), input.get_pos());
|
||||
}
|
||||
|
||||
// A cursor resting on a separator keeps completing the component after it.
|
||||
void
|
||||
TestInputPathInput::test_cursor_on_separator() {
|
||||
input::PathInput input;
|
||||
|
||||
input.str() = m_temp_dir + "/alpha/be";
|
||||
input.set_pos(m_temp_dir.size() + 6);
|
||||
|
||||
CPPUNIT_ASSERT(input.pressed('\t'));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(m_temp_dir + "/alpha/beta/", input.str());
|
||||
CPPUNIT_ASSERT_EQUAL(input.str().size(), input.get_pos());
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "test/helpers/test_fixture.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class TestInputPathInput : public test_fixture {
|
||||
CPPUNIT_TEST_SUITE(TestInputPathInput);
|
||||
|
||||
CPPUNIT_TEST(test_complete_at_end);
|
||||
CPPUNIT_TEST(test_complete_mid_line);
|
||||
CPPUNIT_TEST(test_cursor_on_separator);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
void test_complete_at_end();
|
||||
void test_complete_mid_line();
|
||||
void test_cursor_on_separator();
|
||||
|
||||
private:
|
||||
std::string m_temp_dir;
|
||||
};
|
||||
Reference in New Issue
Block a user