mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 20:52:30 +00:00
* Replaced the old File with the EntryListNode code, and cleaned it
up. The user now uses File* instead of File. * Changed apply_low_diskspace to use torrent::Download::free_diskspace() instead of the old file path hack. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@809 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -98,9 +98,9 @@ WindowFileList::redraw() {
|
||||
Range range = rak::advance_bidirectional<unsigned int>(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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user