diff --git a/src/storage.cpp b/src/storage.cpp index 0468684f3..ae4834d5e 100755 --- a/src/storage.cpp +++ b/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.end()); 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/src/torrent.cpp b/src/torrent.cpp index 8a5626216..24ea63b7a 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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")); + } } }