From 6b90e1d16cdcd5436237d41d46c955ff10cb56e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCchel?= Date: Tue, 26 Nov 2019 00:43:00 +0100 Subject: [PATCH] remove a costy is_dir-check on obvious directories to speed up a pull --- webdav3/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webdav3/client.py b/webdav3/client.py index 42a510c..3d29207 100644 --- a/webdav3/client.py +++ b/webdav3/client.py @@ -691,6 +691,7 @@ class Client(object): urn = Urn(remote_directory, directory=True) + ## here we check for the current directory if not self.is_dir(urn.path()): raise OptionNotValid(name="remote_path", value=remote_directory) @@ -699,6 +700,7 @@ class Client(object): local_resource_names = listdir(local_directory) + ## here we get all files and directories in the current directory paths = self.list(urn.path()) expression = "{begin}{end}".format(begin="^", end=remote_directory) remote_resource_names = prune(paths, expression) @@ -711,9 +713,12 @@ class Client(object): remote_urn = Urn(remote_path) - if self.is_dir(remote_urn.path()): + ## if the string ends with an "/" it *must* be a directory + ## no need to check it here + if remote_urn.path().endswith("/"): if not os.path.exists(local_path): os.mkdir(local_path) + ## nevertheless, since we pull the directory, it will be checked up there self.pull(remote_directory=remote_path, local_directory=local_path) else: if remote_resource_name in local_resource_names: