Adds mount_remote_dir
Adds the mount_remote_dir method to the synchroniser, this allows to mount the remote directory in order to access it with the generated links. Also adds the background parameter to the documentation of update_links
This commit is contained in:
@@ -7,6 +7,8 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Synchroniser:
|
class Synchroniser:
|
||||||
@@ -141,7 +143,7 @@ class Synchroniser:
|
|||||||
First calls cleanlinks to remove deadlinks and empty directories.
|
First calls cleanlinks to remove deadlinks and empty directories.
|
||||||
Then calls lndir to create the new links.
|
Then calls lndir to create the new links.
|
||||||
Args:
|
Args:
|
||||||
-
|
- background: controls if the update is done in the background or waited for
|
||||||
"""
|
"""
|
||||||
|
|
||||||
link_update_script = (f"cd {self.remote_dir}/links && "
|
link_update_script = (f"cd {self.remote_dir}/links && "
|
||||||
@@ -168,3 +170,21 @@ class Synchroniser:
|
|||||||
link_update_process.wait()
|
link_update_process.wait()
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
|
def mount_remote_dir(self):
|
||||||
|
"""
|
||||||
|
Mount the remote directory to make the local links work.
|
||||||
|
This is achieved using sshfs.
|
||||||
|
Raise:
|
||||||
|
- subprocess.CalledProcessError: An error occured with sshfs
|
||||||
|
"""
|
||||||
|
command = [
|
||||||
|
"/usr/bin/sshfs",
|
||||||
|
"-o", "ControlPath={self.control_path}",
|
||||||
|
"-o", "ServerAliveInterval=15",
|
||||||
|
"-p", str(self.remote_port),
|
||||||
|
f"{self.remote_user}@{self.remote_ip}:{self.remote_dir}/.data",
|
||||||
|
# Get the absolute path to the correct .data directory resolving symlinks
|
||||||
|
str(Path(f"{self.local}/../.data").resolve())
|
||||||
|
]
|
||||||
|
completed_process = subprocess.run(command)
|
||||||
|
completed_process.check_returncode()
|
||||||
|
|||||||
Reference in New Issue
Block a user