backups: Make mountpoint property private

It is not required by any consumers. Allows for better abstraction on a complex
class.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-28 15:21:47 -07:00 committed by James Valleroy
parent d05bbab751
commit 143c9e494d
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -370,7 +370,7 @@ class SshBorgRepository(BaseBorgRepository):
return self._mountpoint return self._mountpoint
@property @property
def mountpoint(self): def _mountpoint(self):
"""Return the local mount point where repository is to be mounted.""" """Return the local mount point where repository is to be mounted."""
return os.path.join(self.SSHFS_MOUNTPOINT, self.uuid) return os.path.join(self.SSHFS_MOUNTPOINT, self.uuid)
@ -378,7 +378,7 @@ class SshBorgRepository(BaseBorgRepository):
def is_mounted(self): def is_mounted(self):
"""Return whether remote path is mounted locally.""" """Return whether remote path is mounted locally."""
output = self._run('sshfs', output = self._run('sshfs',
['is-mounted', '--mountpoint', self.mountpoint]) ['is-mounted', '--mountpoint', self._mountpoint])
return json.loads(output) return json.loads(output)
def mount(self): def mount(self):
@ -387,7 +387,7 @@ class SshBorgRepository(BaseBorgRepository):
return return
known_hosts_path = get_known_hosts_path() known_hosts_path = get_known_hosts_path()
arguments = [ arguments = [
'mount', '--mountpoint', self.mountpoint, '--path', self._path, 'mount', '--mountpoint', self._mountpoint, '--path', self._path,
'--user-known-hosts-file', '--user-known-hosts-file',
str(known_hosts_path) str(known_hosts_path)
] ]
@ -400,20 +400,20 @@ class SshBorgRepository(BaseBorgRepository):
if not self.is_mounted: if not self.is_mounted:
return return
self._run('sshfs', ['umount', '--mountpoint', self.mountpoint]) self._run('sshfs', ['umount', '--mountpoint', self._mountpoint])
def remove(self): def remove(self):
"""Remove a repository from the kvstore and delete its mountpoint""" """Remove a repository from the kvstore and delete its mountpoint"""
self.umount() self.umount()
store.delete(self.uuid) store.delete(self.uuid)
try: try:
if os.path.exists(self.mountpoint): if os.path.exists(self._mountpoint):
try: try:
self.umount() self.umount()
except ActionError: except ActionError:
pass pass
if not os.listdir(self.mountpoint): if not os.listdir(self._mountpoint):
os.rmdir(self.mountpoint) os.rmdir(self._mountpoint)
except Exception as err: except Exception as err:
logger.error(err) logger.error(err)