* Some views were using uninitialized bool for reversing.

* Possibly hash_done gets called while a download is closed.

* Consider putting chunk release before receive_chunkdone.

* Don't use getopt to check for flags as that re-orders the left-over
arguments.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@696 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-05-21 00:11:07 +00:00
parent 271e8e6ccf
commit 770d205b9a
4 changed files with 28 additions and 30 deletions
+19 -19
View File
@@ -140,7 +140,7 @@ DownloadFactory::receive_commit() {
void
DownloadFactory::receive_success() {
if (m_stream == NULL)
throw torrent::client_error("DownloadFactory::receive_success() called on an object with m_stream == NULL");
throw torrent::client_error("DownloadFactory::receive_success() called on an object with m_stream == NULL.");
Download* download = m_manager->download_list()->create(m_stream, m_printLog);
@@ -167,14 +167,6 @@ DownloadFactory::receive_success() {
initialize_rtorrent(download, rtorrent);
if (m_manager->download_list()->insert(download) == m_manager->download_list()->end()) {
// ATM doesn't really ever get here.
delete download;
m_slotFinished();
return;
}
// Move to 'rtorrent'.
download->variable()->set("connection_leech", m_variables.get("connection_leech"));
download->variable()->set("connection_seed", m_variables.get("connection_seed"));
@@ -185,12 +177,25 @@ DownloadFactory::receive_success() {
if (!control->variable()->get_value("use_udp_trackers"))
download->enable_udp_trackers(false);
if (m_session) {
if (!rtorrent->has_key_string("directory"))
download->variable()->set("directory", m_variables.get("directory"));
else
download->variable()->set("directory", rtorrent->get_key("directory"));
if (!rtorrent->has_key_string("directory"))
download->variable()->set("directory", m_variables.get("directory"));
else
download->variable()->set("directory", rtorrent->get_key("directory"));
if (!m_session && m_variables.get("tied_to_file").as_value())
download->variable()->set("tied_to_file", m_uri);
// The action of inserting might cause the torrent to be
// opened/started or such. Figure out a nicer way of handling this.
if (m_manager->download_list()->insert(download) == m_manager->download_list()->end()) {
// ATM doesn't really ever get here.
delete download;
m_slotFinished();
return;
}
if (m_session) {
// This torrent was queued for hashing or hashing when the session
// file was saved. Or it was in a started state.
if (download->variable()->get_value("hashing") != Download::variable_hashing_stopped ||
@@ -198,11 +203,6 @@ DownloadFactory::receive_success() {
m_manager->download_list()->resume(download);
} else {
download->variable()->set("directory", m_variables.get("directory"));
if (m_variables.get("tied_to_file").as_value())
download->variable()->set("tied_to_file", m_uri);
// Use the state thingie here, move below.
if (m_start)
m_manager->download_list()->start(download);
+3
View File
@@ -371,6 +371,9 @@ void
DownloadList::hash_done(Download* download) {
check_contains(download);
if (!download->is_open())
throw torrent::client_error("DownloadList::hash_done(...) !download->is_open().");
if (!download->is_hash_checked() || download->is_hash_checking() || download->is_active())
throw torrent::client_error("DownloadList::hash_done(...) download in invalid state.");
+1 -1
View File
@@ -83,7 +83,7 @@ private:
class ViewSortVariableValue : public ViewSort {
public:
ViewSortVariableValue(const std::string& name, bool reverse = false) :
m_name(name) {}
m_name(name), m_reverse(reverse) {}
virtual bool operator () (Download* d1, Download* d2) const {
if (m_reverse)
+5 -10
View File
@@ -36,7 +36,10 @@
#include "config.h"
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <functional>
#include <getopt.h>
#include <stdexcept>
#include <unistd.h>
@@ -88,17 +91,9 @@ OptionParser::process(int argc, char** argv) {
bool
OptionParser::has_flag(char flag, int argc, char** argv) {
int result;
char options[2] = { flag, '\0' };
char options[3] = { '-', flag, '\0' };
optind = 0;
opterr = 0;
while ((result = getopt(argc, argv, options)) != -1)
if (result == flag)
return true;
return false;
return std::find_if(argv, argv + argc, std::not1(std::bind1st(std::ptr_fun(&std::strcmp), options))) != argv + argc;
}
std::string