From 480eb0a077b229477ff336318523c99ba2f0927a Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Fri, 28 Jun 2019 15:31:10 +0700 Subject: [PATCH] Optimize ssh makedirs --- dvc/remote/ssh/connection.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dvc/remote/ssh/connection.py b/dvc/remote/ssh/connection.py index 0f6bd9d5a..5bdf58f97 100644 --- a/dvc/remote/ssh/connection.py +++ b/dvc/remote/ssh/connection.py @@ -97,10 +97,13 @@ class SSHConnection: def makedirs(self, path): self._sftp_connect() - if self.isdir(path): + # Single stat call will say whether this is a dir, a file or a link + st_mode = self.st_mode(path) + + if stat.S_ISDIR(st_mode): return - if self.isfile(path) or self.islink(path): + if stat.S_ISREG(st_mode) or stat.S_ISLNK(st_mode): raise DvcException( "a file with the same name '{}' already exists".format(path) )