From 8e51cad8de8a5450d463b78909035a385131691a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 10 Sep 2024 11:23:18 +0200 Subject: [PATCH] posixfs: also accept relative paths, see #23 URLS now might look like: - file:///absolute/path - file://relative/path (*) Internally, PosixFS now: - accepts relative paths as path argument - always works with an absolute .base_path internally (*) not sure if that is the final solution, consider this as a temporary hack. --- src/borgstore/backends/posixfs.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/borgstore/backends/posixfs.py b/src/borgstore/backends/posixfs.py index aaf3f45..4421fff 100644 --- a/src/borgstore/backends/posixfs.py +++ b/src/borgstore/backends/posixfs.py @@ -15,10 +15,12 @@ def get_file_backend(url): - # file:///var/backups/borgstore/first + # file:///absolute/path + # or + # file://relative/path (temporary hack, might change in future) file_regex = r""" file:// - (?P(/.*)) + (?P(.*)) """ m = re.match(file_regex, url, re.VERBOSE) if m: @@ -27,7 +29,7 @@ def get_file_backend(url): class PosixFS(BackendBase): def __init__(self, path, *, do_fsync=False): - self.base_path = Path(path) + self.base_path = Path(path).absolute() self.opened = False self.do_fsync = do_fsync # False = 26x faster, see #10