diff --git a/src/layman/layer/filesystem/input_chunk.py b/src/layman/layer/filesystem/input_chunk.py index 144a8b2a0..f3f61d138 100644 --- a/src/layman/layer/filesystem/input_chunk.py +++ b/src/layman/layer/filesystem/input_chunk.py @@ -138,7 +138,10 @@ def get_layer_info(workspace, layername): if info: files_to_upload = info['files_to_upload'] file_names = [file['input_file'] for file in files_to_upload] - file_type = input_file.get_file_type(input_file.get_main_file_name(file_names)) + if len(file_names) == 1 and input_file.get_compressed_main_file_extension(file_names[0]): + file_type = settings.FILE_TYPE_UNKNOWN + else: + file_type = input_file.get_file_type(input_file.get_main_file_name(file_names)) result = {'file': {'file_type': file_type}} return result diff --git a/src/layman/layer/rest_workspace_layer.py b/src/layman/layer/rest_workspace_layer.py index cc3351a72..0f001946a 100644 --- a/src/layman/layer/rest_workspace_layer.py +++ b/src/layman/layer/rest_workspace_layer.py @@ -69,6 +69,8 @@ def patch(workspace, layername): ] if len(files) > 0: use_chunk_upload = True + if len(files) == 1 and input_file.get_compressed_main_file_extension(files[0]): + zipped_file = files[0] # CRS crs_id = None @@ -106,14 +108,17 @@ def patch(workspace, layername): # FILE NAMES filenames = None if delete_from == 'layman.layer.filesystem.input_file': - if use_chunk_upload: + if use_chunk_upload and zipped_file: + filenames = list() + elif use_chunk_upload: filenames = files elif zipped_file: filenames = fs_util.get_filenames_from_zip_storage(zipped_file, with_zip_in_path=True) else: filenames = [f.filename for f in files] - input_file.check_filenames(workspace, layername, filenames, - check_crs, ignore_existing_files=True) + if not (use_chunk_upload and zipped_file): + input_file.check_filenames(workspace, layername, filenames, + check_crs, ignore_existing_files=True) # file checks if not use_chunk_upload: temp_dir = tempfile.mkdtemp(prefix="layman_") diff --git a/src/layman/layer/util.py b/src/layman/layer/util.py index 219a0a2a7..67140c13e 100644 --- a/src/layman/layer/util.py +++ b/src/layman/layer/util.py @@ -3,7 +3,7 @@ from flask import current_app, request, g -from layman import LaymanError, patch_mode, util as layman_util +from layman import LaymanError, patch_mode, util as layman_util, settings from layman.util import call_modules_fn, get_providers_from_source_names, get_internal_sources, \ to_safe_name, url_for from layman import celery as celery_util, common @@ -75,7 +75,7 @@ def check_new_layername(workspace, layername): def fill_in_partial_info_statuses(info, chain_info): file_type = info.get('file', dict()).get('file_type') - item_keys = get_layer_info_keys(file_type) if file_type else None + item_keys = get_layer_info_keys(file_type) if file_type else settings.FILE_TYPE_UNKNOWN return layman_util.fill_in_partial_info_statuses(info, chain_info, TASKS_TO_LAYER_INFO_KEYS, item_keys) diff --git a/tests/dynamic_data/publications.py b/tests/dynamic_data/publications.py index a91d0d117..00303ee95 100644 --- a/tests/dynamic_data/publications.py +++ b/tests/dynamic_data/publications.py @@ -339,6 +339,31 @@ }), ], }, + { + consts.KEY_ACTION: { + consts.KEY_CALL: Action(process_client.patch_workspace_publication, { + **predefined_zip_files.NE_110M_ADMIN_0_BOUNDARY_LINES_LAND, + 'with_chunks': True, + }), + consts.KEY_RESPONSE_ASSERTS: [ + Action(processing.response.valid_post, dict()), + ], + }, + consts.KEY_FINAL_ASSERTS: [ + *publication.IS_LAYER_COMPLETE_AND_CONSISTENT, + Action(publication.internal.correct_values_in_detail, { + 'exp_publication_detail': { + 'bounding_box': [-15695801.072582014, -7341864.739114417, 15699816.562538767, 11122367.192100529], + }, + 'file_extension': 'zip/ne_110m_admin_0_boundary lines land +ěščřžýáí/ne_110m_admin_0_boundary_lines_land ížě.shp', + 'gdal_prefix': '/vsizip/', + 'publ_type_detail': ('vector', 'sld'), + }), + Action(publication.internal.thumbnail_equals, { + 'exp_thumbnail': 'test_tools/data/thumbnail/ne_110m_admin_0_boundary_lines_land.png', + }), + ], + }, ], Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_shp_sld'): [ { @@ -366,6 +391,31 @@ }), ], }, + { + consts.KEY_ACTION: { + consts.KEY_CALL: Action(process_client.patch_workspace_publication, { + **predefined_zip_files.SMALL_LAYER_ZIP, + 'with_chunks': True, + }), + consts.KEY_RESPONSE_ASSERTS: [ + Action(processing.response.valid_post, dict()), + ], + }, + consts.KEY_FINAL_ASSERTS: [ + *publication.IS_LAYER_COMPLETE_AND_CONSISTENT, + Action(publication.internal.correct_values_in_detail, { + 'exp_publication_detail': { + 'bounding_box': [1571204.369948366, 6268896.225570714, 1572590.854206196, 6269876.33561699], + }, + 'file_extension': 'zip/small_layer.geojson', + 'gdal_prefix': '/vsizip/', + 'publ_type_detail': ('vector', 'sld'), + }), + Action(publication.internal.thumbnail_equals, { + 'exp_thumbnail': 'sample/style/basic_sld.png', + }), + ], + }, ], Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_tif_tfw_rgba_opaque'): [ { @@ -393,6 +443,31 @@ }), ], }, + { + consts.KEY_ACTION: { + consts.KEY_CALL: Action(process_client.patch_workspace_publication, { + **predefined_zip_files.SAMPLE_TIF_COLORTABLE_NODATA_OPAQUE, + 'with_chunks': True, + }), + consts.KEY_RESPONSE_ASSERTS: [ + Action(processing.response.valid_post, dict()), + ], + }, + consts.KEY_FINAL_ASSERTS: [ + *publication.IS_LAYER_COMPLETE_AND_CONSISTENT, + Action(publication.internal.correct_values_in_detail, { + 'exp_publication_detail': { + 'bounding_box': [868376.0, 522128.0, 940583.0, 593255.0], + }, + 'file_extension': 'zip/sample_tif_colortable_nodata_opaque/sample_tif_colortable_nodata_opaque.tif', + 'gdal_prefix': '/vsizip/', + 'publ_type_detail': ('raster', 'sld'), + }), + Action(publication.internal.thumbnail_equals, { + 'exp_thumbnail': 'test_tools/data/thumbnail/raster_layer_tif_colortable_nodata_opaque.png', + }), + ], + }, ], Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_tif_colortable_nodata_opaque'): [ { @@ -420,5 +495,30 @@ }), ], }, + { + consts.KEY_ACTION: { + consts.KEY_CALL: Action(process_client.patch_workspace_publication, { + **predefined_zip_files.SAMPLE_TIF_TFW_RGBA_OPAQUE, + 'with_chunks': True, + }), + consts.KEY_RESPONSE_ASSERTS: [ + Action(processing.response.valid_post, dict()), + ], + }, + consts.KEY_FINAL_ASSERTS: [ + *publication.IS_LAYER_COMPLETE_AND_CONSISTENT, + Action(publication.internal.correct_values_in_detail, { + 'exp_publication_detail': { + 'bounding_box': [1669480.0, 6580973.000000007, 1675351.9999999802, 6586999.0], + }, + 'file_extension': 'zip/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque.tif', + 'gdal_prefix': '/vsizip/', + 'publ_type_detail': ('raster', 'sld'), + }), + Action(publication.internal.thumbnail_equals, { + 'exp_thumbnail': 'test_tools/data/thumbnail/raster_layer_tiff.png', + }), + ], + }, ], }