diff --git a/src/borg/legacyrepository.py b/src/borg/legacyrepository.py index 5e626316e..930c209a9 100644 --- a/src/borg/legacyrepository.py +++ b/src/borg/legacyrepository.py @@ -27,6 +27,7 @@ from .platform import SaveFile, SyncFile, sync_dir, safe_fadvise from .repoobj import RepoObj from .checksums import crc32, StreamingXXH64 from .crypto.file_integrity import IntegrityCheckedFile, FileIntegrityError +from .repository import _local_abspath_to_file_url logger = create_logger(__name__) @@ -191,7 +192,7 @@ class LegacyRepository: def __init__(self, path, create=False, exclusive=False, lock_wait=None, lock=True, send_log_cb=None): self.path = os.path.abspath(path) - self._location = Location("file://%s" % self.path) + self._location = Location(_local_abspath_to_file_url(self.path)) self.version = None # long-running repository methods which emit log or progress output are responsible for calling # the ._send_log method periodically to get log and progress output transferred to the borg client diff --git a/src/borg/repository.py b/src/borg/repository.py index c4bd6f6e9..2fa873ede 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -106,7 +106,7 @@ class Repository: if isinstance(path_or_location, Location): location = path_or_location if location.proto == "file": - url = _local_abspath_to_file_url(location.path) # frequently users give without file:// prefix + url = _local_abspath_to_file_url(location.path) else: url = location.processed # location as given by user, processed placeholders else: diff --git a/src/borg/testsuite/archiver/lock_cmds_test.py b/src/borg/testsuite/archiver/lock_cmds_test.py index 295fa1d5e..150b0e61d 100644 --- a/src/borg/testsuite/archiver/lock_cmds_test.py +++ b/src/borg/testsuite/archiver/lock_cmds_test.py @@ -9,6 +9,7 @@ from ...constants import * # NOQA from . import cmd, generate_archiver_tests, RK_ENCRYPTION from ...helpers import CommandError from ...platformflags import is_haiku +from ...repository import _local_abspath_to_file_url pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA @@ -23,7 +24,7 @@ def test_break_lock(archivers, request): def test_with_lock(tmp_path): repo_path = tmp_path / "repo" env = os.environ.copy() - env["BORG_REPO"] = "file://" + str(repo_path) + env["BORG_REPO"] = _local_abspath_to_file_url(str(repo_path.absolute())) # test debug output: print("sys.path: %r" % sys.path) print("PYTHONPATH: %s" % env.get("PYTHONPATH", "")) diff --git a/src/borg/testsuite/storelocking_test.py b/src/borg/testsuite/storelocking_test.py index ea091a83b..d39f055b2 100644 --- a/src/borg/testsuite/storelocking_test.py +++ b/src/borg/testsuite/storelocking_test.py @@ -4,6 +4,7 @@ import pytest from borgstore.store import Store +from ..repository import _local_abspath_to_file_url from ..storelocking import Lock, NotLocked, LockTimeout ID1 = "foo", 1, 1 @@ -11,8 +12,9 @@ ID2 = "bar", 2, 2 @pytest.fixture() -def lockstore(tmpdir): - store = Store("file://" + str(tmpdir / "lockstore"), levels={"locks/": [0]}) +def lockstore(tmp_path): + lockstore_path = tmp_path / "lockstore" + store = Store(_local_abspath_to_file_url(str(lockstore_path.absolute())), levels={"locks/": [0]}) store.create() with store: yield store