Skip to content

Commit 53d7e36

Browse files
Fix migration (#181)
* Fix migration for datastes without files * Fix handler for raster in case of copy and missing files
1 parent e344740 commit 53d7e36

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

importer/handlers/common/raster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ def copy_raster_file(
504504

505505
original_dataset = original_dataset.first()
506506

507+
if not original_dataset.files:
508+
raise InvalidGeoTiffException("The original file of the dataset is not available, Is not possible to copy the dataset")
509+
507510
new_file_location = orchestrator.load_handler(handler_module_path).copy_original_file(original_dataset)
508511

509512
new_dataset_alternate = create_alternate(original_dataset.title, exec_id)

importer/migrations/0006_dataset_migration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ def dataset_migration(apps, _):
1010
.exclude(pk__in=NewResources.objects.values_list('resource_id', flat=True))\
1111
.exclude(subtype__in=['remote', None]):
1212
# generating orchestrator expected data file
13-
converted_files = [{"base_file": x} for x in old_resource.files]
13+
if not old_resource.files:
14+
if old_resource.is_vector():
15+
converted_files = [{"base_file": "placeholder.shp"}]
16+
else:
17+
converted_files = [{"base_file": "placeholder.tiff"}]
18+
else:
19+
converted_files = [{"base_file": x} for x in old_resource.files]
1420
# try to get the handler for the file of the old resource
1521
# when is found, we can exit
1622
handler_to_use = None

0 commit comments

Comments
 (0)