From 0ffd52a83699f4074bd7a39e5bc9a0fac9858a02 Mon Sep 17 00:00:00 2001 From: Alexander Schepanovski Date: Fri, 28 Jun 2019 15:29:56 +0700 Subject: [PATCH] remote: fix ssh makedirs race Closes #1862 --- dvc/remote/ssh/connection.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dvc/remote/ssh/connection.py b/dvc/remote/ssh/connection.py index 6bcd2ed3e..0f6bd9d5a 100644 --- a/dvc/remote/ssh/connection.py +++ b/dvc/remote/ssh/connection.py @@ -1,6 +1,7 @@ import os import posixpath import logging +import errno import stat from contextlib import contextmanager @@ -110,7 +111,13 @@ class SSHConnection: self.makedirs(head) if tail: - self._sftp.mkdir(path) + try: + self._sftp.mkdir(path) + except IOError as e: + # Since paramiko errors are very vague we need to recheck + # whether it's because path already exists or something else + if e.errno == errno.EACCES or not self.exists(path): + raise def walk(self, directory, topdown=True): # NOTE: original os.walk() implementation [1] with default options was