fix move_storage bug when using fail_if_exist as well as use the boost::system::errc::file_exists as error code for that case

This commit is contained in:
Arvid Norberg 2013-05-11 03:54:18 +00:00
parent b925534c59
commit 4607e36c6f
2 changed files with 11 additions and 2 deletions

View File

@ -2643,7 +2643,9 @@ source directory and the target directory.
overwrite. If it would, it will fail. Otherwise it will proceed as if it was in
``always_replace_files`` mode. Note that there is an inherent race condition here.
If the files in the target directory appear after the check but before the copy
or move completes, they will be overwritten.
or move completes, they will be overwritten. When failing because of files already
existing in the target path, the ``error`` of ``move_storage_failed_alert`` is set
to ``boost::system::errc::file_exists``.
The intention is that a client may use this as a probe, and if it fails, ask the user
which mode to use. The client may then re-issue the ``move_storage`` call with one

View File

@ -2241,7 +2241,14 @@ namespace libtorrent
#endif
TORRENT_ASSERT(j.buffer == 0);
ret = j.storage->move_storage_impl(j.str, j.piece);
if (ret != 0)
if (ret != piece_manager::file_exist)
{
j.error = error_code(boost::system::errc::file_exists, get_system_category());
j.error_file = -1;
j.buffer = NULL;
break;
}
if (ret != piece_manager::no_error && ret != piece_manager::need_full_check)
{
test_error(j);
break;