diff --git a/dpdispatcher/ssh_context.py b/dpdispatcher/ssh_context.py index 1f07f231..ff40cdcc 100644 --- a/dpdispatcher/ssh_context.py +++ b/dpdispatcher/ssh_context.py @@ -334,8 +334,9 @@ def upload(self, try: self.ssh_session.sftp.mkdir(os.path.basename(self.remote_root)) except OSError: - # mkdir failed meaning it exists, thus the job is recovered - recover = True + # mkdir failed meaning it exists + if len(self.ssh_session.sftp.listdir(os.path.basename(self.remote_root))): + recover = True self.ssh_session.sftp.chdir(None) cwd = os.getcwd()