Skip to content

Commit

Permalink
Thrash.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jan 12, 2025
1 parent 3d2cfa3 commit 23c74f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 11 additions & 1 deletion python/insta_science/_internal/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .hashing import Digest, ExpectedDigest, Fingerprint
from .model import Url
from .version import __version__
from .. import Platform

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -133,7 +134,16 @@ def _vet_request(url: Url, method: str = "GET") -> tuple[Request, Path] | Respon
if request.method not in ("GET", "HEAD"):
return Response(status_code=codes.METHOD_NOT_ALLOWED, request=request)

path = Path(urllib.parse.unquote_plus(url.info.path))
raw_path = urllib.parse.unquote_plus(url.info.path)
if Platform.current().is_windows:
# Handle `file:///C:/a/path` -> `C:/a/path`.
parts = raw_path.split("/")
if ":" == parts[1][-1]:
parts.pop(0)
path = Path("/".join(parts))
else:
path = Path(raw_path)

if not path.exists():
return Response(status_code=codes.NOT_FOUND, request=request)
if not path.is_file():
Expand Down
2 changes: 0 additions & 2 deletions python/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def test_download_file_mirror(pyproject_toml: Path, tmp_path: Path) -> None:
"""
)
)
if Platform.current().is_windows:
assert False, os.linesep.join((str(pyproject_toml), pyproject_toml.read_text()))

subprocess.run(args=["insta-science-util", "download", mirror_dir], check=True)
subprocess.run(args=["insta-science", "-V"], check=True)

0 comments on commit 23c74f2

Please sign in to comment.