Downloaded file names keep the URL query string, invalid on Windows
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Đọc climada/util/files_handler.py quanh dòng 81 và climada/util/api_client.py quanh dòng 567, nơi issue chỉ ra việc trích xuất tên tệp dựa trên URL. Kiểm tra các bài kiểm tra hiện có cho những đường dẫn tải xuống này và bổ sung kiểm thử cho URL có chuỗi truy vấn. Công việc hoàn tất khi cả hai đường dẫn tạo ra tên tệp cục bộ không có chuỗi truy vấn và trường hợp tái hiện trên Windows không còn gây lỗi tên tệp không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
download_file derives the local filename from the URL using url.split("/")[-1], which keeps the query string (climada/util/files_handler.py:81). The configured distance-to-coast URL ends in ?download=1, so the filename becomes GMT_intermediate_coast_distance_01d.zip?download=1. Since ? is not a valid character in Windows filenames, Centroids.get_dist_coast raises OSError: [Errno 22].
The same pattern is at climada/util/api_client.py:567.
To Reproduce
Steps to reproduce the behavior/error:
- On Windows, with no
GMT_intermediate_coast_distance_01d.tifin~/climada/data - Run the code below
Code example:
from climada.util.coordinates import dist_to_coast_nasa
dist_to_coast_nasa([46.0], [8.0])
# OSError: [Errno 22] Invalid argument:
# '...\\climada\\data\\GMT_intermediate_coast_distance_01d.zip?download=1'
Expected behavior
The query string is not part of the file name. Proposed fix at both sites:
from pathlib import PurePosixPath
from urllib.parse import urlsplit
file_name = PurePosixPath(urlsplit(url).path).name
# api_client.py: path /= unquote(PurePosixPath(urlsplit(url).path).name)
Happy to open a PR.
Screenshots
n/a
Climada Version: 6.1.1-dev (develop)
System Information (please complete the following information):
- Operating system and version: Windows 11 (10.0.26200)
- Python version: 3.12.13
Additional context
n/a
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 478
- Fork
- 166
- Merge trung bình
- 2 ngày 31 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CLIMADA-project/climada_python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CLIMADA-project/climada_python#1337 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
CartoDB basemaps now need an API key (somewhat urgent)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CLIMADA-project/climada_python#1332 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
more than 20 open figuresĐang mởwarnings
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CLIMADA-project/climada_python#1241 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
ResourceWarningĐang mởwarnings
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CLIMADA-project/climada_python#1239 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
implicit `set_geometry`Đang mởwarnings
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CLIMADA-project/climada_python#1226 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của CLIMADA-project/climada_python
Issue tương tự
-
fix(api): optimize-for-web /preview outer catches miss asDecoderOutOfMemory on V8 OOM and SIGKILLĐang mởarea: backend bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
snapotter-hq/SnapOtter#3773 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
khuisman/mcp-gee-sweet#1166 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
control-plane security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Usenova-Labs/usenova-backend#29 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
gramaziokohler/compas_timber#870 ·
-
queue stdout mixes human notices with JSON: move trailer + compact notice + receipt text to stderrĐang mởarea: queue-scope bug confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mvschwarz/openrig#1806 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày