edit empty trackers fix

This commit is contained in:
Marcos Pinto 2007-11-16 20:11:58 +00:00
parent 2a8d36029e
commit 5a90e14794
4 changed files with 29 additions and 9 deletions

View File

@ -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<std::string> directories;
typedef std::set<std::string>::iterator iter_t;
@ -493,13 +495,21 @@ namespace libtorrent
std::pair<iter_t, bool> 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<std::string>::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

View File

@ -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"));
}
}
}

View File

@ -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

View File

@ -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)