diff --git a/docs/manual.rst b/docs/manual.rst index 16d44e874..364a62499 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -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 diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 21a1a4691..6cec6a167 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -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;