From 5a79b80f326890826e953de35d97b2680210b913 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 5 May 2021 20:21:33 -0400 Subject: [PATCH] fixes #322, do not error out deleting files that have assocaited data stores, just remove the data store. --- crc/services/file_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crc/services/file_service.py b/crc/services/file_service.py index 16b16f5e..3d8a1e39 100644 --- a/crc/services/file_service.py +++ b/crc/services/file_service.py @@ -14,6 +14,7 @@ from sqlalchemy.exc import IntegrityError from crc import session, app from crc.api.common import ApiError +from crc.models.data_store import DataStoreModel from crc.models.file import FileType, FileDataModel, FileModel, LookupFileModel, LookupDataModel from crc.models.workflow import WorkflowSpecModel, WorkflowModel, WorkflowSpecDependencyFile from crc.services.cache_service import cache @@ -392,6 +393,7 @@ class FileService(object): session.query(LookupDataModel).filter_by(lookup_file_model_id=lf.id).delete() session.query(LookupFileModel).filter_by(id=lf.id).delete() session.query(FileDataModel).filter_by(file_model_id=file_id).delete() + session.query(DataStoreModel).filter_by(file_id=file_id).delete() session.query(FileModel).filter_by(id=file_id).delete() session.commit() except IntegrityError as ie: