fix error handling when directories in the target are missing
This commit is contained in:
parent
4fdaa40e37
commit
1ce4b2b531
|
@ -514,7 +514,8 @@ namespace libtorrent
|
||||||
// if old_name doesn't exist, that's not an error
|
// if old_name doesn't exist, that's not an error
|
||||||
// here. Once we start writing to the file, it will
|
// here. Once we start writing to the file, it will
|
||||||
// be written to the new filename
|
// be written to the new filename
|
||||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
if (ec && ec != boost::system::errc::no_such_file_or_directory
|
||||||
|
&& ec != boost::system::errc::not_a_directory)
|
||||||
{
|
{
|
||||||
set_error(old_name, ec);
|
set_error(old_name, ec);
|
||||||
return true;
|
return true;
|
||||||
|
@ -540,7 +541,8 @@ namespace libtorrent
|
||||||
error_code ec;
|
error_code ec;
|
||||||
remove(p, ec);
|
remove(p, ec);
|
||||||
|
|
||||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
if (ec && ec != boost::system::errc::no_such_file_or_directory
|
||||||
|
&& ec != boost::system::errc::not_a_directory)
|
||||||
set_error(p, ec);
|
set_error(p, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +758,8 @@ namespace libtorrent
|
||||||
error_code ec;
|
error_code ec;
|
||||||
file_status s;
|
file_status s;
|
||||||
stat_file(save_path, &s, ec);
|
stat_file(save_path, &s, ec);
|
||||||
if (ec == boost::system::errc::no_such_file_or_directory)
|
if (ec == boost::system::errc::no_such_file_or_directory
|
||||||
|
|| ec == boost::system::errc::not_a_directory)
|
||||||
create_directories(save_path, ec);
|
create_directories(save_path, ec);
|
||||||
else if (ec)
|
else if (ec)
|
||||||
return false;
|
return false;
|
||||||
|
@ -781,7 +784,8 @@ namespace libtorrent
|
||||||
std::string new_path = combine_path(save_path, *i);
|
std::string new_path = combine_path(save_path, *i);
|
||||||
|
|
||||||
rename(old_path, new_path, ec);
|
rename(old_path, new_path, ec);
|
||||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
if (ec && ec != boost::system::errc::no_such_file_or_directory
|
||||||
|
&& ec != boost::system::errc::not_a_directory)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
recursive_copy(old_path, new_path, ec);
|
recursive_copy(old_path, new_path, ec);
|
||||||
|
@ -1155,7 +1159,9 @@ ret:
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
file_handle = open_file(file_iter, op.mode, ec);
|
file_handle = open_file(file_iter, op.mode, ec);
|
||||||
if (((op.mode & file::rw_mask) == file::read_write) && ec == boost::system::errc::no_such_file_or_directory)
|
if (((op.mode & file::rw_mask) == file::read_write)
|
||||||
|
&& (ec == boost::system::errc::no_such_file_or_directory
|
||||||
|
|| ec == boost::system::errc::not_a_directory))
|
||||||
{
|
{
|
||||||
// this means the directory the file is in doesn't exist.
|
// this means the directory the file is in doesn't exist.
|
||||||
// so create it
|
// so create it
|
||||||
|
@ -1286,7 +1292,9 @@ ret:
|
||||||
TORRENT_ASSERT((aligned_size & size_align) == 0);
|
TORRENT_ASSERT((aligned_size & size_align) == 0);
|
||||||
|
|
||||||
size_type actual_file_size = file_handle->get_size(ec);
|
size_type actual_file_size = file_handle->get_size(ec);
|
||||||
if (ec && ec != make_error_code(boost::system::errc::no_such_file_or_directory)) return -1;
|
if (ec && ec != boost::system::errc::no_such_file_or_directory
|
||||||
|
&& ec != boost::system::errc::not_a_directory)
|
||||||
|
return -1;
|
||||||
ec.clear();
|
ec.clear();
|
||||||
|
|
||||||
// allocate a temporary, aligned, buffer
|
// allocate a temporary, aligned, buffer
|
||||||
|
|
Loading…
Reference in New Issue