diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 23ffdc6b9..e1501e67c 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -217,11 +217,16 @@ namespace libtorrent void swap(file_storage& ti) { using std::swap; - swap(ti.m_piece_length, m_piece_length); swap(ti.m_files, m_files); + swap(ti.m_file_hashes, m_file_hashes); + swap(ti.m_symlinks, m_symlinks); + swap(ti.m_mtime, m_mtime); + swap(ti.m_file_base, m_file_base); + swap(ti.m_paths, m_paths); + swap(ti.m_name, m_name); swap(ti.m_total_size, m_total_size); swap(ti.m_num_pieces, m_num_pieces); - swap(ti.m_name, m_name); + swap(ti.m_piece_length, m_piece_length); } // if pad_file_limit >= 0, files larger than diff --git a/src/storage.cpp b/src/storage.cpp index 349c99a57..cbad8a08c 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -727,6 +727,9 @@ namespace libtorrent bool storage::verify_resume_data(lazy_entry const& rd, error_code& error) { + // TODO: make this more generic to not just work if files have been + // renamed, but also if they have been merged into a single file for instance + // maybe use the same format as .torrent files and reuse some code from torrent_info lazy_entry const* mapped_files = rd.dict_find_list("mapped_files"); if (mapped_files && mapped_files->list_size() == m_files.num_files()) { diff --git a/src/torrent.cpp b/src/torrent.cpp index 5cc5a9323..663624324 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4270,17 +4270,6 @@ namespace libtorrent prioritize_udp_trackers(); } - lazy_entry const* mapped_files = rd.dict_find_list("mapped_files"); - if (mapped_files && mapped_files->list_size() == m_torrent_file->num_files()) - { - for (int i = 0; i < m_torrent_file->num_files(); ++i) - { - std::string new_filename = mapped_files->list_string_value_at(i); - if (new_filename.empty()) continue; - m_torrent_file->rename_file(i, new_filename); - } - } - lazy_entry const* url_list = rd.dict_find_list("url-list"); if (url_list) { @@ -4489,7 +4478,10 @@ namespace libtorrent } // write renamed files - if (&m_torrent_file->files() != &m_torrent_file->orig_files()) + // TODO: make this more generic to not just work if files have been + // renamed, but also if they have been merged into a single file for instance + if (&m_torrent_file->files() != &m_torrent_file->orig_files() + && m_torrent_file->files().num_files() == m_torrent_file->orig_files().num_files()) { entry::list_type& fl = ret["mapped_files"].list(); for (torrent_info::file_iterator i = m_torrent_file->begin_files()