Skip to content

Commit

Permalink
Fix migration (#181)
Browse files Browse the repository at this point in the history
* Fix migration for datastes without files

* Fix handler for raster in case of copy and missing files
  • Loading branch information
mattiagiupponi authored May 30, 2023
1 parent e344740 commit 53d7e36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions importer/handlers/common/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion importer/migrations/0006_dataset_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53d7e36

Please sign in to comment.