From ea139d2ec7dadc59fcdb7ea40d30d6f01f65baa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20H=C3=A5kansson?= Date: Tue, 18 Jun 2019 08:53:41 +0200 Subject: [PATCH] Added depth_to_copy argument in copy method in client.py Implemented support to control the depth http header for the copy command. --- webdav3/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webdav3/client.py b/webdav3/client.py index 0eb0452..92bb4ee 100644 --- a/webdav3/client.py +++ b/webdav3/client.py @@ -500,12 +500,13 @@ class Client(object): threading.Thread(target=target).start() @wrap_connection_error - def copy(self, remote_path_from, remote_path_to): + def copy(self, remote_path_from, remote_path_to, depth=1): """Copies resource from one place to another on WebDAV server. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_COPY :param remote_path_from: the path to resource which will be copied, :param remote_path_to: the path where resource will be copied. + :param depth: folder depth to copy """ urn_from = Urn(remote_path_from) if not self.check(urn_from.path()): @@ -516,7 +517,8 @@ class Client(object): raise RemoteParentNotFound(urn_to.path()) header_destination = "Destination: {path}".format(path=self.get_full_path(urn_to)) - self.execute_request(action='copy', path=urn_from.quote(), headers_ext=[header_destination]) + header_depth = "Depth: {depth}".format(depth=depth) + self.execute_request(action='copy', path=urn_from.quote(), headers_ext=[header_destination, header_depth]) @wrap_connection_error def move(self, remote_path_from, remote_path_to, overwrite=False):