CloudPolis / webdav-client-cpp

:cloud: C++ WebDAV Client provides easy and convenient to work with WebDAV-servers.
http://cloudpolis.github.io/webdav-client-cpp/
Other
120 stars 52 forks source link

Recursive loop when trying to create recursive folder with no internet connection #47

Closed horde3d closed 6 years ago

horde3d commented 6 years ago

When trying to create a directory recursively when there is no internet connection available, the call to create_directory runs in an endless loop. The check call will fail, because of the recursive flag being true, another call to create_directory will be done that again runs into create_directory and so on:

https://github.com/CloudPolis/webdav-client-cpp/blob/fafcb660a79ff34079e6063b5abb3e8d13aa84bd/sources/client.cpp#L595

By adding a check if the parent directory is unequal to the original directory this can be avoided:

auto remote_parent_directory = directory_urn.parent().path();
if( remote_parent_directory == remote_directory )
     return false;
bool is_created = this->create_directory(remote_parent_directory, response, true);
if (!is_created) return false;