OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
853 stars 311 forks source link

[Bug] Download Natural Earth Dataset in WGS84 prints error message #4657

Closed tmszi closed 3 weeks ago

tmszi commented 3 weeks ago

Describe the bug

Download Natural Earth Dataset in WGS84 prints error message.

To reproduce

  1. Launch wxGUI
  2. From the Data catalog toolbar launch Download sample project (location) to current GRASS database dialog
  3. From the dialog sample project choice widget choose Natural Earth Dataset in WGS84
  4. Hit download button
  5. On the end of downloading dataset process you get error message which is printed in dialog

_Download of https://zenodo.org/records/13370131/files/natural_earth_dataset.zip failed or file </tmp/grass8-test-18250/tmpds5ohiix/archive.zip> is not a ZIP file_

Expected behavior

Download Natural Earth Dataset via wxGUI should work as expected without prints error message.

Screenshots

loc_download_dialog_error_message

System description

GRASS fire_grass6data/demomapset:tmp > g.version -rge
version=8.5.0dev
date=2024
revision=1b9482cae
build_date=2024-11-05
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=ba0a49519
libgis_date=2024-10-31T16:49:36+00:00
proj=9.4.1
gdal=3.8.5
geos=3.12.1
sqlite=3.46.1
GRASS fire_grass6data/demomapset:tmp > python -c "import sys, wx; print(sys.version); print(wx.version())"
3.12.7 (main, Oct 28 2024, 10:22:17) [GCC 13.3.1 20240614]
4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1

Additional context

Problematic is following code condition (line 173-178) which is not sufficient in case of downloading Natural Earth Dataset in WGS84 ZIP file from the URL https://zenodo.org/records/13370131/files/natural_earth_dataset.zip where the server response returns two headers (content-type: application/octet-stream and content-disposition: attachment; filename=natural_earth_dataset.zip) that identify the ZIP file.

https://github.com/OSGeo/grass/blob/039183d9be2c1baf6e63fc07f6554fe6c2a06276/python/grass/utils/download.py#L173-L178

Get server response header with Curl (see content-type: application/octet-stream and content-disposition: attachment; filename=natural_earth_dataset.zip header):

test@test:/tmp$ curl -I  https://zenodo.org/records/13370131/files/natural_earth_dataset.zip 
HTTP/1.1 200 OK
server: nginx
content-type: application/octet-stream
content-length: 121322068
content-security-policy: default-src 'self' fonts.googleapis.com *.gstatic.com data: 'unsafe-inline' 'unsafe-eval' blob: zenodo-broker.web.cern.ch zenodo-broker-qa.web.cern.ch maxcdn.bootstrapcdn.com cdnjs.cloudflare.com ajax.googleapis.com webanalytics.web.cern.ch
x-content-type-options: nosniff
x-download-options: noopen
x-permitted-cross-domain-policies: none
x-frame-options: sameorigin
x-xss-protection: 1; mode=block
content-disposition: attachment; filename=natural_earth_dataset.zip
last-modified: Mon, 30 Sep 2024 01:12:39 GMT
date: Tue, 05 Nov 2024 19:52:51 GMT
link: <https://zenodo.org/api/records/13370131> ; rel="linkset" ; type="application/linkset+json"
x-ratelimit-limit: 133
x-ratelimit-remaining: 130
x-ratelimit-reset: 1730836384
retry-after: 12
permissions-policy: interest-cohort=()
strict-transport-security: max-age=31556926; includeSubDomains
referrer-policy: strict-origin-when-cross-origin
set-cookie: session=957524b09e088504_672a7793.515i9U5MnmVnxk4dRl1PrWhnfH4; Expires=Fri, 15 Nov 2024 19:52:51 GMT; Secure; HttpOnly; Path=/; SameSite=Lax
strict-transport-security: max-age=15768000
x-request-id: 527ed04385d57cc86a58507dc34e454a
set-cookie: 5569e5a730cade8ff2b54f1e815f3670=c41b72347a319657b4b11be06886d96a; path=/; HttpOnly; Secure; SameSite=None
cache-control: private

Server response Content-Type: application/octet-stream header RFC 2046 states in section 4.5.1:

The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

Server response Content-Disposition header doc.