From dc2243c17e175077ab007135ff7b09dcfbc2c0c2 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 1 Jan 2014 02:04:26 +0000 Subject: [PATCH] add moving_storage field to torrent_status --- ChangeLog | 1 + include/libtorrent/torrent.hpp | 5 ++++- include/libtorrent/torrent_handle.hpp | 5 +++++ src/torrent.cpp | 5 +++++ src/torrent_handle.cpp | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aab521c88..845529107 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * add moving_storage field to torrent_status * expose UPnP and NAT-PMP mapping in session object * DHT refactoring and support for storing arbitrary data with put * support building on android diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 24cb79f20..6e2efadca 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1346,7 +1346,10 @@ namespace libtorrent // more blocks to disk! bool m_deleted:1; - // TODO: there's space for another 2 bits here + // set to true while moving the storage + bool m_moving_storage:1; + + // TODO: there's space for another bit here // ---- diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 42d3bdfee..615016abf 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -1431,6 +1431,11 @@ namespace libtorrent // checked or as soon as one piece fails the hash check. bool seed_mode; + // this is true if this torrent's storage is currently being moved from + // one location to another. This may potentially be a long operation + // if a large file ends up being copied from one drive to another. + bool moving_storage; + // the info-hash for this torrent sha1_hash info_hash; }; diff --git a/src/torrent.cpp b/src/torrent.cpp index a4b7a927a..411be0860 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -299,6 +299,7 @@ namespace libtorrent , m_is_active_finished(false) , m_ssl_torrent(false) , m_deleted(false) + , m_moving_storage(false) , m_incomplete(0xffffff) , m_abort(false) , m_announce_to_dht((p.flags & add_torrent_params::flag_paused) == 0) @@ -6506,6 +6507,7 @@ namespace libtorrent #endif m_owning_storage->async_move_storage(path, flags , boost::bind(&torrent::on_storage_moved, shared_from_this(), _1, _2)); + m_moving_storage = true; } else { @@ -6526,6 +6528,8 @@ namespace libtorrent { TORRENT_ASSERT(m_ses.is_network_thread()); + m_moving_storage = false; + if (ret == piece_manager::no_error || ret == piece_manager::need_full_check) { if (alerts().should_post()) @@ -8699,6 +8703,7 @@ namespace libtorrent st->has_incoming = m_has_incoming; if (m_error) st->error = convert_from_native(m_error.message()) + ": " + m_error_file; st->seed_mode = m_seed_mode; + st->moving_storage = m_moving_storage; st->added_time = m_added_time; st->completed_time = m_completed_time; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index a9e222d51..14c1a2509 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -140,6 +140,7 @@ namespace libtorrent , has_metadata(false) , has_incoming(false) , seed_mode(false) + , moving_storage(false) , info_hash(0) {}