|
7 | 7 | from asyncio import Queue, QueueEmpty |
8 | 8 | from collections.abc import AsyncIterator |
9 | 9 | from pathlib import Path |
| 10 | +from pathlib import PurePosixPath as ObjectPath |
10 | 11 | from typing import Any, TypeAlias |
11 | 12 |
|
12 | 13 | import anyio |
@@ -259,8 +260,8 @@ async def destroy_cache(self) -> None: |
259 | 260 |
|
260 | 261 | async def list_object_paths(store: ObjectStore, prefix: str) -> list[str]: |
261 | 262 | objects = await obs.list(store, prefix).collect_async() |
262 | | - prefix_path = Path(prefix) |
263 | | - return sorted(str(Path(obj["path"]).relative_to(prefix_path)) for obj in objects) |
| 263 | + prefix_path = ObjectPath(prefix) |
| 264 | + return sorted(str(ObjectPath(obj["path"]).relative_to(prefix_path)) for obj in objects) |
264 | 265 |
|
265 | 266 |
|
266 | 267 | async def download_objects( # noqa: PLR0913 |
@@ -299,7 +300,7 @@ async def _download_worker( |
299 | 300 | async def _download_object( |
300 | 301 | store: ObjectStore, prefix: str, obj: str, output_dir: Path, show_progress: bool = True |
301 | 302 | ) -> Path: |
302 | | - key = str(Path(prefix) / obj) |
| 303 | + key = str(ObjectPath(prefix) / obj) |
303 | 304 | output_path = output_dir / obj |
304 | 305 | if output_path.exists(): # already cached |
305 | 306 | return output_path |
@@ -609,7 +610,7 @@ async def _list_objects(self, datapoint: xr.Dataset | CopernicusStorageGranule) |
609 | 610 | granule = CopernicusStorageGranule.from_data(datapoint) |
610 | 611 | # special handling for Sentinel-5P, where the location is not a folder but a single file |
611 | 612 | if granule.location.endswith(".nc"): |
612 | | - return [Path(granule.granule_name).name] |
| 613 | + return [str(ObjectPath(granule.granule_name))] |
613 | 614 |
|
614 | 615 | return await list_object_paths(self._store, _copernicus_s3_prefix(granule)) |
615 | 616 |
|
|
0 commit comments