Skip to content

Commit

Permalink
sftp: fixup (race condition / style)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Sep 15, 2024
1 parent 9e4e8d6 commit abb53ce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/borgstore/backends/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ def _connect(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
config_path = Path("~/.ssh/config").expanduser()
if config_path.exists():
try:
sc = paramiko.SSHConfig.from_path(str(config_path))
scd = sc.lookup(self.hostname)
else:
except FileNotFoundError:
scd = paramiko.SSHConfigDict() # empty dict
else:
scd = sc.lookup(self.hostname)
ssh.connect(
hostname=scd.get("hostname", self.hostname),
username=scd.get("user", self.username),
Expand Down

0 comments on commit abb53ce

Please sign in to comment.