Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to change save path without moving any files #7469

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion include/libtorrent/storage_defs.hpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -110,7 +111,15 @@ 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,

// 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
Expand Down
7 changes: 7 additions & 0 deletions src/storage_utils.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -199,6 +200,12 @@ 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<bool, file_index_t> copied_files(std::size_t(f.num_files()), false);
Expand Down
Loading