Skip to content

Commit

Permalink
sftp: raise BackendDoesNotExist if base path is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Sep 28, 2024
1 parent b273ed1 commit 38301f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/borgstore/backends/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def open(self):
if self.opened:
raise BackendMustNotBeOpen()
self._connect()
st = self.client.stat(self.base_path) # check if this storage exists, fail early if not.
try:
st = self.client.stat(self.base_path) # check if this storage exists, fail early if not.
except FileNotFoundError:
raise BackendDoesNotExist(f"sftp storage base path does not exist: {self.base_path}")
if not stat.S_ISDIR(st.st_mode):
raise BackendDoesNotExist(f"sftp storage base path is not a directory: {self.base_path}")
self.client.chdir(self.base_path) # this sets the cwd we work in!
Expand Down

0 comments on commit 38301f6

Please sign in to comment.