SFTP client: add missing connect() call in get_file and open_file methods
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Benjamin Renard 2022-06-30 14:46:43 +02:00
parent e858cb3d71
commit 6adcc1eeed

View file

@ -103,11 +103,13 @@ class SFTPClient(ConfigurableObject):
def get_file(self, remote_filepath, local_filepath): def get_file(self, remote_filepath, local_filepath):
""" Retrieve a file from SFTP server """ """ Retrieve a file from SFTP server """
self.connect()
log.debug("Retreive file '%s' to '%s'", remote_filepath, local_filepath) log.debug("Retreive file '%s' to '%s'", remote_filepath, local_filepath)
return self.sftp_client.get(remote_filepath, local_filepath) is None return self.sftp_client.get(remote_filepath, local_filepath) is None
def open_file(self, remote_filepath, mode='r'): def open_file(self, remote_filepath, mode='r'):
""" Remotly open a file on SFTP server """ """ Remotly open a file on SFTP server """
self.connect()
log.debug("Remotly open file '%s'", remote_filepath) log.debug("Remotly open file '%s'", remote_filepath)
return self.sftp_client.open(remote_filepath, mode=mode) return self.sftp_client.open(remote_filepath, mode=mode)