Skip to content

Commit 77f04fc

Browse files
szachovyCopilot
andcommitted
Make create_directory() idempotent to support re-runs
Wrap sftp_client.mkdir() in try/except IOError to silently handle the case where the directory already exists. This follows the same pattern already used by upload_directory() in the same file. Closes #35 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ab8ce7 commit 77f04fc

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626

2727
* Fixed `run_mysql_server()` not instantiating `MySQLServer` class. (#94)
2828
* Disabled MD060 markdownlint rule to fix table column style false positives in documentation. (#94)
29+
* Made `create_directory()` idempotent to support deployment re-runs. (#35)
2930

3031
## 1.0 - 2024-10-13
3132

src/remote.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def upload_directory(self, local_directory_path: str, remote_directory_path: str
152152
self.sftp_client.put(local_item_path, remote_item_path)
153153

154154
def create_directory(self, remote_directory_path: str) -> None:
155-
self.sftp_client.mkdir(remote_directory_path)
155+
try:
156+
self.sftp_client.mkdir(remote_directory_path)
157+
except IOError:
158+
pass
156159

157160
def upload_file(self, content: str | bytes, remote_file_path: str) -> None:
158161
if isinstance(content, str):

0 commit comments

Comments
 (0)