From 8d8d160b35e30e3926faf5918bc81a28aa8a65d7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 Mar 2013 00:50:33 +0000 Subject: [PATCH] a bit more robust error messaging when deleting files in a torrent --- include/libtorrent/torrent.hpp | 2 +- src/session_impl.cpp | 8 +++++++- src/torrent.cpp | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index a279019ff..eed1d6582 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -280,7 +280,7 @@ namespace libtorrent bool should_check_files() const; - void delete_files(); + bool delete_files(); // ============ start deprecation ============= void filter_piece(int index, bool filter); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f116b6a70..59ea6d9b3 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5279,7 +5279,13 @@ retry: torrent& t = *i->second; if (options & session::delete_files) - t.delete_files(); + { + if (!t.delete_files()) + { + if (alerts().should_post()) + alerts().post_alert(torrent_delete_failed_alert(t.get_handle(), error_code())); + } + } tptr->update_guage(); diff --git a/src/torrent.cpp b/src/torrent.cpp index fdb92ecea..c250d8e31 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6976,7 +6976,7 @@ namespace libtorrent return limit; } - void torrent::delete_files() + bool torrent::delete_files() { TORRENT_ASSERT(m_ses.is_network_thread()); @@ -6992,7 +6992,9 @@ namespace libtorrent TORRENT_ASSERT(m_storage); m_storage->async_delete_files( boost::bind(&torrent::on_files_deleted, shared_from_this(), _1, _2)); + return true; } + return false; } void torrent::clear_error()