From 5a90e147940e4d825584510ca2d079e972ebf2d2 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 16 Nov 2007 20:11:58 +0000 Subject: [PATCH] edit empty trackers fix --- libtorrent/src/storage.cpp | 16 +++++++++++++--- libtorrent/src/torrent.cpp | 11 +++++++++-- src/core.py | 10 +++++++--- src/interface.py | 1 - 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index 0468684f3..cf0781e6a 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -478,6 +478,8 @@ namespace libtorrent m_files.release(this); buffer().swap(m_scratch_buffer); + std::string error; + // delete the files from disk std::set directories; typedef std::set::iterator iter_t; @@ -493,13 +495,21 @@ namespace libtorrent std::pair ret = directories.insert((m_save_path / bp).string()); bp = bp.branch_path(); } - std::remove(p.c_str()); + if (std::remove(p.c_str()) != 0 && errno != ENOENT) + error = std::strerror(errno); } // remove the directories. Reverse order to delete // subdirectories first - std::for_each(directories.rbegin(), directories.rend() - , bind((int(*)(char const*))&std::remove, bind(&std::string::c_str, _1))); + + for (std::set::reverse_iterator i = directories.rbegin() + , end(directories.rend()); i != end; ++i) + { + if (std::remove(i->c_str()) != 0 && errno != ENOENT) + error = std::strerror(errno); + } + + if (!error.empty()) throw std::runtime_error(error); } void storage::write_resume_data(entry& rd) const diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 8a5626216..b71555f0f 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -498,7 +498,7 @@ namespace libtorrent { INVARIANT_CHECK; - if (m_torrent_file->trackers().empty()) return false; + if (m_trackers.empty()) return false; if (m_just_paused) { @@ -1072,7 +1072,14 @@ namespace libtorrent if (alerts().should_post(alert::warning)) { - alerts().post_alert(torrent_deleted_alert(get_handle(), "files deleted")); + if (ret != 0) + { + alerts().post_alert(torrent_deleted_alert(get_handle(), "delete files failed: " + j.str)); + } + else + { + alerts().post_alert(torrent_deleted_alert(get_handle(), "files deleted")); + } } } diff --git a/src/core.py b/src/core.py index 23f5def7c..30d78cae1 100644 --- a/src/core.py +++ b/src/core.py @@ -1010,11 +1010,15 @@ of HD space! Oops!\nWe had to pause at least one torrent")) return deluge_core.pe_settings(out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4) def get_trackers(self, unique_ID): - return deluge_core.get_trackers(unique_ID) + if self.unique_IDs[unique_ID].trackers: + return self.unique_IDs[unique_ID].trackers + else: + return deluge_core.get_trackers(unique_ID) - def replace_trackers(self, unique_ID, trackers): + def replace_trackers(self, unique_ID, trackerslist): + self.unique_IDs[unique_ID].trackers = trackerslist try: - return deluge_core.replace_trackers(unique_ID, trackers) + return deluge_core.replace_trackers(unique_ID, trackerslist) except: pass diff --git a/src/interface.py b/src/interface.py index 98ff6de82..3a5634883 100644 --- a/src/interface.py +++ b/src/interface.py @@ -490,7 +490,6 @@ window, please enter your password")) include_hidden_chars=False).strip() self.manager.replace_trackers(torrent, self.textlist) self.edit_window.destroy() - self.manager.unique_IDs[torrent].trackers = self.textlist def show_edit_tracker_dialog(self, list): self.textbuffer = gtk.TextBuffer(table=None)