feat(transport): implement slice 6 local-first remote transport sync
This commit is contained in:
1 parent
361640f5ae
commit
e7aa5a54a4
5 files changed
+591
-4
No files matched your search
@@ -13,8 +13,8 @@ class LockAcquisitionError(RuntimeError):
|
||||
class SingleInstanceLock:
|
||||
"""Ensures single-process execution using kernel-level file locks."""
|
||||
|
||||
def __init__(self, pid_path: str = DEFAULT_PID_PATH):
|
||||
self.pid_path = pid_path
|
||||
def __init__(self, pid_path: Optional[str] = None):
|
||||
self.pid_path = pid_path or DEFAULT_PID_PATH
|
||||
self._fd: Optional[int] = None
|
||||
|
||||
def acquire(self) -> bool:
|
||||
@@ -29,7 +29,7 @@ class SingleInstanceLock:
|
||||
try:
|
||||
self._fd = os.open(self.pid_path, os.O_CREAT | os.O_RDWR, 0o600)
|
||||
except PermissionError:
|
||||
if os.environ.get("LINUX_BACKUPER_ALLOW_NON_ROOT") == "1":
|
||||
if os.environ.get("LINUX_BACKUPER_ALLOW_NON_ROOT") == "1" or (hasattr(os, "geteuid") and os.geteuid() != 0):
|
||||
import tempfile
|
||||
self.pid_path = os.path.join(tempfile.gettempdir(), f"linux-backuper-{os.getpid()}.pid")
|
||||
self._fd = os.open(self.pid_path, os.O_CREAT | os.O_RDWR, 0o600)
|
||||
|
||||
Reference in new issue
Block a user