Skip to content

Commit

Permalink
Merge pull request #248 from hujay2019/bug_fix
Browse files Browse the repository at this point in the history
Check the existence of the remote file before transferring the file
  • Loading branch information
jan-janssen authored Jan 1, 2024
2 parents 52d5808 + b4172b7 commit fbdc565
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pysqa/ext/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def _transfer_files(self, file_dict, sftp=None, transfer_back=False):
for file_src, file_dst in tqdm(file_dict.items()):
if transfer_back:
try:
# Check remote file existence.
# If the remote file does not exist, sftp_client.get() will make the local file empty
# sftp_client.stat() can throw an exception early to prevent the execution of sftp_client.get().
sftp_client.stat(file_dst)
sftp_client.get(file_dst, file_src)
except FileNotFoundError:
pass
Expand Down

0 comments on commit fbdc565

Please sign in to comment.