diff --git a/src/command_download.cc b/src/command_download.cc index 1c01039c..d9cabb43 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -174,6 +174,29 @@ apply_d_delete_tied(core::Download* download) { void 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()) download->set_root_directory(name); else if (name.empty() || *name.rbegin() == '/') diff --git a/src/core/range_map.h b/src/core/range_map.h index 1f1bf8fc..9b60dcb6 100644 --- a/src/core/range_map.h +++ b/src/core/range_map.h @@ -58,8 +58,13 @@ public: RangeMap() {} RangeMap(const Compare& c) : base_type(c) {} - using base_type::const_iterator; - using base_type::const_reverse_iterator; + typedef typename base_type::iterator 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::swap; @@ -76,22 +81,22 @@ public: using base_type::value_comp; // 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. - 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(). - 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. - 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. - T get(const Key& key, T def) const; + T get(const Key& key, T def) const; 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: diff --git a/src/display/window_download_statusbar.cc b/src/display/window_download_statusbar.cc index e44172e4..00783cbc 100644 --- a/src/display/window_download_statusbar.cc +++ b/src/display/window_download_statusbar.cc @@ -68,7 +68,7 @@ WindowDownloadStatusbar::redraw() { position = print_download_info(buffer, last, m_download); m_canvas->print(0, 0, "%s", buffer); - position = buffer + std::min(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(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()->peer_list()->available_list_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_complete(), (int)m_download->download()->peers_accounted(), + (int)m_download->info()->upload_unchoked(), + (int)m_download->info()->download_unchoked(), (int)m_download->chunks_failed()), 0), last - buffer); diff --git a/src/rpc/command.h b/src/rpc/command.h index f7a89657..ba73bd12 100644 --- a/src/rpc/command.h +++ b/src/rpc/command.h @@ -86,8 +86,8 @@ struct rt_triple : private std::pair { using base_type::first; using base_type::second; - using base_type::first_type; - using base_type::second_type; + using typename base_type::first_type; + using typename base_type::second_type; T3 third;