Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the existence of the remote file before transferring the file #248

Merged
merged 3 commits into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading