diff --git a/src/display/window_file_list.cc b/src/display/window_file_list.cc index b4f1d2f2..7fd5aeac 100644 --- a/src/display/window_file_list.cc +++ b/src/display/window_file_list.cc @@ -98,9 +98,9 @@ WindowFileList::redraw() { Range range = rak::advance_bidirectional(0, *m_focus, fl.size(), m_canvas->height() - pos); while (range.first != range.second) { - torrent::File e = fl.get(range.first); + torrent::File* e = fl.get(range.first); - std::string path = e.path_str(); + std::string path = e->path()->as_string(); if (path.length() <= 50) path = path + std::string(50 - path.length(), ' '); @@ -109,7 +109,7 @@ WindowFileList::redraw() { std::string priority; - switch (e.priority()) { + switch (e->priority()) { case torrent::PRIORITY_OFF: priority = "off"; break; @@ -130,16 +130,16 @@ WindowFileList::redraw() { m_canvas->print(0, pos, "%c %s %6.1f %s %3d %9s", range.first == *m_focus ? '*' : ' ', path.c_str(), - (double)e.size_bytes() / (double)(1 << 20), + (double)e->size_bytes() / (double)(1 << 20), priority.c_str(), done_percentage(e), - e.path()->encoding().c_str()); + e->path()->encoding().c_str()); m_canvas->print(84, pos, "%i - %i %c%c", - e.chunk_begin(), - e.chunk_begin() != e.chunk_end() ? (e.chunk_end() - 1) : e.chunk_end(), - e.is_created() ? 'E' : 'M', - e.is_correct_size() ? 'C' : 'W'); + e->range().first, + e->range().first != e->range().second ? (e->range().second - 1) : e->range().second, + e->is_created() ? 'E' : 'M', + e->is_correct_size() ? 'C' : 'W'); ++range.first; ++pos; @@ -148,10 +148,10 @@ WindowFileList::redraw() { } int -WindowFileList::done_percentage(torrent::File& e) { - int chunks = e.chunk_end() - e.chunk_begin(); +WindowFileList::done_percentage(torrent::File* e) { + int chunks = e->range().second - e->range().first; - return chunks ? (e.completed_chunks() * 100) / chunks : 100; + return chunks ? (e->completed_chunks() * 100) / chunks : 100; } } diff --git a/src/display/window_file_list.h b/src/display/window_file_list.h index e59d929c..7e9f2612 100644 --- a/src/display/window_file_list.h +++ b/src/display/window_file_list.h @@ -60,7 +60,7 @@ public: virtual void redraw(); private: - int done_percentage(torrent::File& e); + int done_percentage(torrent::File* e); core::Download* m_download; diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc index 37c3e0c1..4f06dd5c 100644 --- a/src/option_handler_rules.cc +++ b/src/option_handler_rules.cc @@ -175,17 +175,11 @@ apply_close_low_diskspace(Control* m, int64_t arg) { core::Manager::DListItr itr = m->core()->download_list()->begin(); while ((itr = std::find_if(itr, m->core()->download_list()->end(), std::mem_fun(&core::Download::is_downloading))) != m->core()->download_list()->end()) { - rak::fs_stat stat; - std::string path = (*itr)->file_list()->root_dir() + (*itr)->file_list()->get(0).path()->as_string(); - - if (!stat.update(path)) { - m->core()->push_log(std::string("Cannot read free diskspace: ") + strerror(errno) + " for " + path); - - } else if (stat.bytes_avail() < arg) { + if ((*itr)->download()->free_diskspace() < (uint64_t)arg) { m->core()->download_list()->close(*itr); (*itr)->set_hash_failed(true); - (*itr)->set_message(std::string("Low diskspace")); + (*itr)->set_message(std::string("Low diskspace.")); } ++itr; diff --git a/src/ui/element_file_list.cc b/src/ui/element_file_list.cc index d4dcc86f..918bed65 100644 --- a/src/ui/element_file_list.cc +++ b/src/ui/element_file_list.cc @@ -179,9 +179,9 @@ ElementFileList::receive_priority() { if (m_focus >= fl.size()) return; - torrent::File file = fl.get(m_focus); + torrent::File* file = fl.get(m_focus); - file.set_priority(next_priority(file.priority())); + file->set_priority(next_priority(file->priority())); m_download->download()->update_priorities(); m_window->mark_dirty(); @@ -197,10 +197,10 @@ ElementFileList::receive_change_all() { if (m_focus >= fl.size()) return; - Priority p = next_priority(fl.get(m_focus).priority()); + Priority p = next_priority(fl.get(m_focus)->priority()); for (int i = 0, last = fl.size(); i != last; ++i) - fl.get(i).set_priority(p); + fl.get(i)->set_priority(p); m_download->download()->update_priorities(); m_window->mark_dirty();