Skip to content

Commit 7dc7f6b

Browse files
[Fixes #14374] Add deletion of temporary files in case of rollback (#14375)
* [Fixes #14374] Add deletion of temporary files in case of rollback * [Fixes #14374] Fix PR suggestions
1 parent fe0f319 commit 7dc7f6b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

geonode/upload/handlers/common/vector.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ def perform_last_step(execution_id):
420420
for asset in assets:
421421
asset.delete()
422422

423+
BaseVectorFileHandler.__remove_temporary_file(_exec)
424+
425+
@staticmethod
426+
def __remove_temporary_file(_exec):
427+
if not _exec:
428+
return
423429
tmp_data = _exec.input_params.get("temporary_files")
424430
if tmp_data:
425431
# Delete at the end of the operations, the temporary files created at the beginning
@@ -1091,6 +1097,12 @@ def _import_resource_rollback(self, exec_id, instance_name=None, *args, **kwargs
10911097
We use the schema editor directly, because the model itself is not managed
10921098
on creation, but for the delete since we are going to handle, we can use it
10931099
"""
1100+
logger.info(f"Rollback temporary file uploaded for execid: {exec_id} resource published was: {instance_name}")
1101+
try:
1102+
BaseVectorFileHandler.__remove_temporary_file(orchestrator.get_execution_object(exec_id=exec_id))
1103+
except Exception as e:
1104+
logger.warning(f"Failed to remove temporary files during rollback: {e}")
1105+
10941106
logger.info(
10951107
f"Rollback dynamic model & ogr2ogr step in progress for execid: {exec_id} resource published was: {instance_name}"
10961108
)

0 commit comments

Comments
 (0)