Skip to content
Merged
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
4 changes: 4 additions & 0 deletions alephclient/fetchdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from pprint import pprint # noqa
from typing import Optional, Dict
from urllib.parse import urlparse, urljoin

from alephclient.api import AlephAPI

Expand Down Expand Up @@ -36,6 +37,9 @@ def fetch_object(api: AlephAPI, path: Path, entity: Dict, overwrite: bool = Fals
object_path = path.joinpath(file_name)
url = entity.get("links", {}).get("file")
if url is not None:
# Aleph Pro may return relative URLs (e.g. /api/2/archive?token=...)
if not urlparse(url).scheme:
url = urljoin(api.base_url, url)
# Skip existing files after checking file size:
if not overwrite and object_path.exists():
for file_size in entity.get("properties", {}).get("fileSize", []):
Expand Down