mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-14 13:16:17 +00:00
* Properly detect issues with 'd.directory.set' being called after the data files have been moved.
* Added counters for unchoked peers. * CLang fixes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1272 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -174,6 +174,29 @@ apply_d_delete_tied(core::Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
apply_d_directory(core::Download* download, const std::string& name) {
|
apply_d_directory(core::Download* download, const std::string& name) {
|
||||||
|
// If the download is open, hashed and has completed chunks make
|
||||||
|
// sure to verify that the download files are still present.
|
||||||
|
//
|
||||||
|
// This should ensure that no one tries to set the destination
|
||||||
|
// directory 'after' moving files. In cases where the user wants to
|
||||||
|
// override this behavior the download must first be closed or
|
||||||
|
// 'd.directory_base.set' may be used.
|
||||||
|
rak::file_stat file_stat;
|
||||||
|
torrent::FileList* file_list = download->file_list();
|
||||||
|
|
||||||
|
if (download->is_hash_checked() && file_list->completed_chunks() != 0 &&
|
||||||
|
|
||||||
|
(file_list->is_multi_file() ?
|
||||||
|
!file_list->is_root_dir_created() :
|
||||||
|
!file_stat.update(file_list->front()->frozen_path()))) {
|
||||||
|
|
||||||
|
download->set_message("Cannot change the directory of an open download after the files have been moved.");
|
||||||
|
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(download));
|
||||||
|
control->core()->download_list()->close_directly(download);
|
||||||
|
|
||||||
|
throw torrent::input_error("Cannot change the directory of an open download atter the files have been moved.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!download->file_list()->is_multi_file())
|
if (!download->file_list()->is_multi_file())
|
||||||
download->set_root_directory(name);
|
download->set_root_directory(name);
|
||||||
else if (name.empty() || *name.rbegin() == '/')
|
else if (name.empty() || *name.rbegin() == '/')
|
||||||
|
|||||||
+13
-8
@@ -58,8 +58,13 @@ public:
|
|||||||
RangeMap() {}
|
RangeMap() {}
|
||||||
RangeMap(const Compare& c) : base_type(c) {}
|
RangeMap(const Compare& c) : base_type(c) {}
|
||||||
|
|
||||||
using base_type::const_iterator;
|
typedef typename base_type::iterator iterator;
|
||||||
using base_type::const_reverse_iterator;
|
typedef typename base_type::reverse_iterator reverse_iterator;
|
||||||
|
typedef typename base_type::const_iterator const_iterator;
|
||||||
|
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
// using typename base_type::const_iterator;
|
||||||
|
// using typename base_type::const_reverse_iterator;
|
||||||
|
|
||||||
using base_type::clear;
|
using base_type::clear;
|
||||||
using base_type::swap;
|
using base_type::swap;
|
||||||
@@ -76,22 +81,22 @@ public:
|
|||||||
using base_type::value_comp;
|
using base_type::value_comp;
|
||||||
|
|
||||||
// Store a value for the range [begin, end). Returns iterator for the range.
|
// Store a value for the range [begin, end). Returns iterator for the range.
|
||||||
typename RangeMap::const_iterator set_range(const Key& begin, const Key& end, const T& value);
|
const_iterator set_range(const Key& begin, const Key& end, const T& value);
|
||||||
|
|
||||||
// Same, but merge adjacent ranges having the same value. Returns iterator for the merged range.
|
// Same, but merge adjacent ranges having the same value. Returns iterator for the merged range.
|
||||||
typename RangeMap::const_iterator set_merge(Key begin, const Key& end, const T& value);
|
const_iterator set_merge(Key begin, const Key& end, const T& value);
|
||||||
|
|
||||||
// Find range containing the given key, or end().
|
// Find range containing the given key, or end().
|
||||||
typename RangeMap::const_iterator find(const Key& key) const;
|
const_iterator find(const Key& key) const;
|
||||||
|
|
||||||
// Retrieve value for key in a range, throw std::out_of_range if range does not exist.
|
// Retrieve value for key in a range, throw std::out_of_range if range does not exist.
|
||||||
const T& get(const Key& key) const;
|
const T& get(const Key& key) const;
|
||||||
|
|
||||||
// Retrieve value for key in a range, return def if range does not exist.
|
// Retrieve value for key in a range, return def if range does not exist.
|
||||||
T get(const Key& key, T def) const;
|
T get(const Key& key, T def) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename RangeMap::iterator crop_overlap(const Key& begin, const Key& end);
|
iterator crop_overlap(const Key& begin, const Key& end);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Semantics of an entry:
|
// Semantics of an entry:
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ WindowDownloadStatusbar::redraw() {
|
|||||||
position = print_download_info(buffer, last, m_download);
|
position = print_download_info(buffer, last, m_download);
|
||||||
m_canvas->print(0, 0, "%s", buffer);
|
m_canvas->print(0, 0, "%s", buffer);
|
||||||
|
|
||||||
position = buffer + std::min<ptrdiff_t>(std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Failed: %i",
|
position = buffer + std::min<ptrdiff_t>(std::max(snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Uploads: %i U/I/C/A: %i/%i/%i/%i Unchoked: %u/%u Failed: %i",
|
||||||
(int)m_download->download()->connection_list()->size(),
|
(int)m_download->download()->connection_list()->size(),
|
||||||
(int)m_download->download()->peer_list()->available_list_size(),
|
(int)m_download->download()->peer_list()->available_list_size(),
|
||||||
(int)m_download->download()->connection_list()->min_size(),
|
(int)m_download->download()->connection_list()->min_size(),
|
||||||
@@ -78,6 +78,8 @@ WindowDownloadStatusbar::redraw() {
|
|||||||
(int)m_download->download()->peers_currently_interested(),
|
(int)m_download->download()->peers_currently_interested(),
|
||||||
(int)m_download->download()->peers_complete(),
|
(int)m_download->download()->peers_complete(),
|
||||||
(int)m_download->download()->peers_accounted(),
|
(int)m_download->download()->peers_accounted(),
|
||||||
|
(int)m_download->info()->upload_unchoked(),
|
||||||
|
(int)m_download->info()->download_unchoked(),
|
||||||
(int)m_download->chunks_failed()),
|
(int)m_download->chunks_failed()),
|
||||||
0), last - buffer);
|
0), last - buffer);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -86,8 +86,8 @@ struct rt_triple : private std::pair<T1, T2> {
|
|||||||
|
|
||||||
using base_type::first;
|
using base_type::first;
|
||||||
using base_type::second;
|
using base_type::second;
|
||||||
using base_type::first_type;
|
using typename base_type::first_type;
|
||||||
using base_type::second_type;
|
using typename base_type::second_type;
|
||||||
|
|
||||||
T3 third;
|
T3 third;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user