From 53d7e360d220d1094c86ac347a0acdf2b565d91b Mon Sep 17 00:00:00 2001 From: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com> Date: Tue, 30 May 2023 11:13:42 +0200 Subject: [PATCH] Fix migration (#181) * Fix migration for datastes without files * Fix handler for raster in case of copy and missing files --- importer/handlers/common/raster.py | 3 +++ importer/migrations/0006_dataset_migration.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/importer/handlers/common/raster.py b/importer/handlers/common/raster.py index a5cf853f..a7cdb404 100644 --- a/importer/handlers/common/raster.py +++ b/importer/handlers/common/raster.py @@ -504,6 +504,9 @@ def copy_raster_file( original_dataset = original_dataset.first() + if not original_dataset.files: + raise InvalidGeoTiffException("The original file of the dataset is not available, Is not possible to copy the dataset") + new_file_location = orchestrator.load_handler(handler_module_path).copy_original_file(original_dataset) new_dataset_alternate = create_alternate(original_dataset.title, exec_id) diff --git a/importer/migrations/0006_dataset_migration.py b/importer/migrations/0006_dataset_migration.py index 7623c713..651965f3 100644 --- a/importer/migrations/0006_dataset_migration.py +++ b/importer/migrations/0006_dataset_migration.py @@ -10,7 +10,13 @@ def dataset_migration(apps, _): .exclude(pk__in=NewResources.objects.values_list('resource_id', flat=True))\ .exclude(subtype__in=['remote', None]): # generating orchestrator expected data file - converted_files = [{"base_file": x} for x in old_resource.files] + if not old_resource.files: + if old_resource.is_vector(): + converted_files = [{"base_file": "placeholder.shp"}] + else: + converted_files = [{"base_file": "placeholder.tiff"}] + else: + converted_files = [{"base_file": x} for x in old_resource.files] # try to get the handler for the file of the old resource # when is found, we can exit handler_to_use = None