Skip to content

Windows fixes #8727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ jobs:
fail-fast: true
matrix:
include:
- os: ubuntu-22.04
python-version: '3.10'
toxenv: mypy
- os: ubuntu-22.04
python-version: '3.11'
toxenv: docs
- os: ubuntu-22.04
python-version: '3.10'
toxenv: py310-fuse2
- os: ubuntu-22.04
python-version: '3.11'
toxenv: py311-fuse3
- os: ubuntu-24.04
python-version: '3.12'
toxenv: py312-fuse3
- os: ubuntu-24.04
python-version: '3.13'
toxenv: py313-fuse3
Expand Down Expand Up @@ -124,7 +109,7 @@ jobs:

macOS:

needs: linux
if: false # enable/disable macOS build
strategy:
fail-fast: true
matrix:
Expand Down Expand Up @@ -196,10 +181,9 @@ jobs:

windows:

if: false # can be used to temporary disable build
if: true # can be used to temporary disable build
runs-on: windows-latest
timeout-minutes: 120
needs: linux

env:
PY_COLORS: 1
Expand Down
9 changes: 6 additions & 3 deletions src/borg/helpers/parseformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from string import Formatter

from ..logger import create_logger
from ..platformflags import is_windows

logger = create_logger()

Expand Down Expand Up @@ -439,8 +440,9 @@ class Location:
(?P<path>.+)
"""

# abs_path must start with a slash.
abs_path_re = r"(?P<path>/.+)"
abs_path_re_posix = r"(?P<path>/.+)" # abs path must start with a slash.
abs_path_re_win = r"(?P<path>[a-zA-Z]:/.+)" # abs path must start with drive : slash.
abs_path_re = abs_path_re_win if is_windows else abs_path_re_posix

# path may or may not start with a slash.
abs_or_rel_path_re = r"(?P<path>.+)"
Expand All @@ -458,7 +460,8 @@ class Location:

rclone_re = re.compile(r"(?P<proto>rclone):(?P<path>(.*))", re.VERBOSE)

file_or_socket_re = re.compile(r"(?P<proto>(file|socket))://" + abs_path_re, re.VERBOSE)
sep = r"/" if is_windows else r"" # on windows, an addtl. slash is needed
file_or_socket_re = re.compile(r"(?P<proto>(file|socket))://" + sep + abs_path_re, re.VERBOSE)

local_re = re.compile(local_path_re, re.VERBOSE)

Expand Down
4 changes: 3 additions & 1 deletion src/borg/legacyrepository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import errno
from pathlib import Path

import mmap
import os
import shutil
Expand Down Expand Up @@ -192,7 +194,7 @@ class PathPermissionDenied(Error):

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(Path(self.path).as_uri())
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
Expand Down
2 changes: 2 additions & 0 deletions src/borg/platformflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

is_win32 = sys.platform.startswith("win32")
is_cygwin = sys.platform.startswith("cygwin")
is_msys = sys.platform.startswith("msys")
is_windows = is_win32 or is_cygwin or is_msys

is_linux = sys.platform.startswith("linux")
is_freebsd = sys.platform.startswith("freebsd")
Expand Down
5 changes: 3 additions & 2 deletions src/borg/repository.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import time
from pathlib import Path

from borgstore.store import Store
from borgstore.store import ObjectNotFound as StoreObjectNotFound
Expand Down Expand Up @@ -96,11 +97,11 @@ def __init__(self, path_or_location, create=False, exclusive=False, lock_wait=1.
if isinstance(path_or_location, Location):
location = path_or_location
if location.proto == "file":
url = f"file://{location.path}" # frequently users give without file:// prefix
url = Path(location.path).absolute().as_uri() # frequently users give without file:// prefix
else:
url = location.processed # location as given by user, processed placeholders
else:
url = "file://%s" % os.path.abspath(path_or_location)
url = Path(path_or_location).absolute().as_uri()
location = Location(url)
self._location = location
self.url = url
Expand Down
2 changes: 1 addition & 1 deletion src/borg/testsuite/archiver/lock_cmds_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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"] = repo_path.as_uri()
command0 = "python3", "-m", "borg", "repo-create", "--encryption=none"
# timings must be adjusted so that command1 keeps running while command2 tries to get the lock,
# so that lock acquisition for command2 fails as the test expects it.
Expand Down
3 changes: 2 additions & 1 deletion src/borg/testsuite/storelocking_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from pathlib import Path

import pytest

Expand All @@ -12,7 +13,7 @@

@pytest.fixture()
def lockstore(tmpdir):
store = Store("file://" + str(tmpdir / "lockstore"), levels={"locks/": [0]})
store = Store(Path(tmpdir / "lockstore").as_uri(), levels={"locks/": [0]})
store.create()
with store:
yield store
Expand Down
Loading