From 0ba72637f5026fd0e9b4ad5bed24487435a5d137 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 4 Jul 2023 22:18:12 +0300 Subject: [PATCH 1/2] Allow to change save path without moving any files --- include/libtorrent/storage_defs.hpp | 7 ++++++- src/storage_utils.cpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/storage_defs.hpp b/include/libtorrent/storage_defs.hpp index f4c5e3e6d1c..2c2da6badc9 100644 --- a/include/libtorrent/storage_defs.hpp +++ b/include/libtorrent/storage_defs.hpp @@ -1,5 +1,6 @@ /* +Copyright (c) 2023, Vladimir Golovnev Copyright (c) 2006-2007, 2009, 2013-2014, 2016-2020, 2022, Arvid Norberg Copyright (c) 2016, 2021, Alden Torres All rights reserved. @@ -110,7 +111,11 @@ namespace libtorrent { // if any file exist in the target, take those files instead // of the ones we may have in the source. - dont_replace + dont_replace, + + // don't move any source files, just forget about them + // and begin checking files at new save path + reset_save_path }; #if TORRENT_ABI_VERSION == 1 diff --git a/src/storage_utils.cpp b/src/storage_utils.cpp index 239ab256aa4..6cabbe4a073 100644 --- a/src/storage_utils.cpp +++ b/src/storage_utils.cpp @@ -1,5 +1,6 @@ /* +Copyright (c) 2023, Vladimir Golovnev Copyright (c) 2016-2022, Arvid Norberg Copyright (c) 2017-2018, Alden Torres Copyright (c) 2017-2018, Steven Siloti @@ -199,6 +200,9 @@ namespace libtorrent { namespace aux { } } + if (flags == move_flags_t::reset_save_path) + return { status_t::need_full_check, new_save_path }; + // indices of all files we ended up copying. These need to be deleted // later aux::vector copied_files(std::size_t(f.num_files()), false); From 3afba4a8e16fe9a7ffd33a7bcf4dd2ebfd66cada Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (glassez)" Date: Wed, 2 Aug 2023 18:34:12 +0300 Subject: [PATCH 2/2] Allow to change save path without any additional actions --- include/libtorrent/storage_defs.hpp | 6 +++++- src/storage_utils.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/storage_defs.hpp b/include/libtorrent/storage_defs.hpp index 2c2da6badc9..1ad2f56ff1d 100644 --- a/include/libtorrent/storage_defs.hpp +++ b/include/libtorrent/storage_defs.hpp @@ -115,7 +115,11 @@ namespace libtorrent { // don't move any source files, just forget about them // and begin checking files at new save path - reset_save_path + reset_save_path, + + // don't move any source files, just change save path + // and continue working without any checks + reset_save_path_unchecked }; #if TORRENT_ABI_VERSION == 1 diff --git a/src/storage_utils.cpp b/src/storage_utils.cpp index 6cabbe4a073..24dcc47af37 100644 --- a/src/storage_utils.cpp +++ b/src/storage_utils.cpp @@ -203,6 +203,9 @@ namespace libtorrent { namespace aux { if (flags == move_flags_t::reset_save_path) return { status_t::need_full_check, new_save_path }; + if (flags == move_flags_t::reset_save_path_unchecked) + return { status_t::no_error, new_save_path }; + // indices of all files we ended up copying. These need to be deleted // later aux::vector copied_files(std::size_t(f.num_files()), false);