diff --git a/ChangeLog b/ChangeLog index 13311c0f1..576fd4753 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * move_storage did not work for torrents without metadata * improve shutdown time by only announcing to trackers whose IP we know * fix python3 portability issue in python binding * delay 5 seconds before reconnecting socks5 proxy for UDP ASSOCIATE diff --git a/src/torrent.cpp b/src/torrent.cpp index 030b6c8b0..7c4c5ef19 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -8931,12 +8931,17 @@ namespace libtorrent } // if we don't have metadata yet, we don't know anything about the file - // structure and we have to assume we don't have any file. Deleting files - // in this mode would cause us to (recursively) delete m_save_path, which - // is bad. + // structure and we have to assume we don't have any file. if (!valid_metadata()) { - alerts().emplace_alert(get_handle(), m_torrent_file->info_hash()); + if (alerts().should_post()) + alerts().emplace_alert(get_handle(), save_path); +#if TORRENT_USE_UNC_PATHS + std::string path = canonicalize_path(save_path); +#else + std::string const& path = save_path; +#endif + m_save_path = complete(path); return; } diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 2e8926b58..4740bdc4b 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent.hpp" #include "libtorrent/peer_info.hpp" #include "libtorrent/extensions.hpp" +#include "libtorrent/magnet_uri.hpp" #include "settings.hpp" #include #include @@ -502,3 +503,19 @@ TORRENT_TEST(queue) TEST_EQUAL(torrents[3].queue_position(), 4); } +TORRENT_TEST(test_move_storage_no_metadata) +{ + lt::session ses(settings()); + add_torrent_params p; + p.save_path = "save_path"; + error_code ec; + parse_magnet_uri("magnet?xt=urn:btih:abababababababababababababababababababab", p, ec); + torrent_handle h = ses.add_torrent(p); + + TEST_EQUAL(h.status().save_path, complete("save_path")); + + h.move_storage("save_path_1"); + + TEST_EQUAL(h.status().save_path, complete("save_path_1")); +} +