diff --git a/geonode/storage/data_retriever.py b/geonode/storage/data_retriever.py index fa20b8a7d51..c9dcb0aa85a 100644 --- a/geonode/storage/data_retriever.py +++ b/geonode/storage/data_retriever.py @@ -202,7 +202,7 @@ def _unzip(self, zip_name: str) -> Mapping: the_zip = zipfile.ZipFile(zip_file, allowZip64=True) the_zip.extractall(self.temporary_folder) available_choices = get_allowed_extensions() - not_main_files = ['xml', 'sld', 'zip'] + not_main_files = ['xml', 'sld', 'zip', 'kmz'] base_file_choices = [x for x in available_choices if x not in not_main_files] for _file in Path(self.temporary_folder).iterdir(): if any([_file.name.endswith(_ext) for _ext in base_file_choices]): diff --git a/geonode/storage/tests.py b/geonode/storage/tests.py index 68ce413b4bb..853aaf06f0a 100644 --- a/geonode/storage/tests.py +++ b/geonode/storage/tests.py @@ -19,6 +19,7 @@ import io import os import shutil +from django.test import override_settings import gisdata from unittest.mock import patch @@ -584,6 +585,26 @@ def test_zip_file_should_correctly_recognize_main_extension_with_csv(self): _files = storage_manager.get_retrieved_paths() self.assertTrue("example.csv" in _files.get("base_file")) + @override_settings(SUPPORTED_DATASET_FILE_TYPES=[{ + "id": "kmz", + "label": "kmz", + "format": "vector", + "ext": ["kmz"] + }, { + "id": "kml", + "label": "kml", + "format": "vector", + "ext": ["kml"] + }]) + def test_zip_file_should_correctly_recognize_main_extension_with_kmz(self): + # reinitiate the storage manager with the zip file + storage_manager = self.sut(remote_files={"base_file": os.path.join(f"{self.project_root}", "tests/data/Italy.kmz")}) + storage_manager.clone_remote_files() + + self.assertIsNotNone(storage_manager.data_retriever.temporary_folder) + _files = storage_manager.get_retrieved_paths() + self.assertTrue("doc.kml" in _files.get("base_file"), msg=f"files available: {_files}") + def test_zip_file_should_correctly_recognize_main_extension_with_shp(self): # zipping files storage_manager = self.sut(remote_files=self.local_files_paths) diff --git a/geonode/storage/tests/data/Italy.kmz b/geonode/storage/tests/data/Italy.kmz new file mode 100644 index 00000000000..66688fd6798 Binary files /dev/null and b/geonode/storage/tests/data/Italy.kmz differ