Skip to content

Commit

Permalink
[Fixes #12728] 3dtiles download does not keep the folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Nov 20, 2024
1 parent 17c4707 commit 60b8dc0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions geonode/assets/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion geonode/proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,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",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 60b8dc0

Please sign in to comment.