From b74479b1eb87fad4397b8ba5ec03105e2571e510 Mon Sep 17 00:00:00 2001 From: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:55:26 +0100 Subject: [PATCH] [Fixes #12728] 3dtiles download does not keep the folder structure (#12729) (cherry picked from commit 26907531a4f33f4d81a3dd4129df0d6ab4c9d92c) --- geonode/assets/local.py | 6 ++---- geonode/proxy/views.py | 2 +- requirements.txt | 2 +- setup.cfg | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/geonode/assets/local.py b/geonode/assets/local.py index aa8e486c485..97e4a7c7d25 100644 --- a/geonode/assets/local.py +++ b/geonode/assets/local.py @@ -7,7 +7,7 @@ from django.http import HttpResponse, StreamingHttpResponse from django.urls import reverse from django_downloadview import DownloadResponse -from zipstream import ZipStream, walk +from zipstream import ZipStream from geonode.assets.handlers import asset_handler_registry, AssetHandlerInterface, AssetDownloadHandlerInterface from geonode.assets.models import LocalAsset @@ -261,9 +261,7 @@ def create_response( match attachment: case True: logger.info(f"Zipping file '{localfile}' with name '{orig_base}'") - zs = ZipStream(sized=True) - for filepath in walk(LocalAssetHandler._get_managed_dir(asset)): - zs.add_path(filepath, os.path.basename(filepath)) + zs = ZipStream(sized=True).from_path(LocalAssetHandler._get_managed_dir(asset), arcname="/") # closing zip for all contents to be written return StreamingHttpResponse( zs, diff --git a/geonode/proxy/views.py b/geonode/proxy/views.py index fd593728bee..2fa4d0eb051 100644 --- a/geonode/proxy/views.py +++ b/geonode/proxy/views.py @@ -276,7 +276,7 @@ def download(request, resourceid, sender=Dataset): register_event(request, "download", instance) folder = os.path.dirname(dataset_files[0]) - zs = ZipStream.from_path(folder) + zs = ZipStream.from_path(folder, arcname="/") return StreamingHttpResponse( zs, content_type="application/zip", diff --git a/requirements.txt b/requirements.txt index b93c708e801..7be5f92e084 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ rdflib==6.3.2 smart_open==7.0.4 PyMuPDF==1.24.3 defusedxml==0.7.1 -zipstream-ng==1.7.1 +zipstream-ng==1.8.0 # Django Apps django-allauth==0.63.6 diff --git a/setup.cfg b/setup.cfg index 94b5c655a11..95e82fa6d15 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = Deprecated==1.2.14 wrapt==1.16.0 jsonschema==4.22.0 - zipstream-ng==1.7.1 + zipstream-ng==1.8.0 schema==0.7.7 rdflib==6.3.2 smart_open==7.0.4