Skip to content

Commit a369cad

Browse files
authored
Merge pull request #2244 from antgonza/delete-root-analysis-artifact
delete-root-analysis-artifact
2 parents db0a4b6 + 3e17876 commit a369cad

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

qiita_db/artifact.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,12 @@ def delete(cls, artifact_id):
573573
WHERE artifact_id = %s"""
574574
qdb.sql_connection.TRN.add(sql, [artifact_id])
575575

576-
# If the artifact doesn't have parents, we move the files to the
577-
# uploads folder. We also need to nullify the column in the prep
578-
# template table
579-
if not instance.parents:
580-
qdb.util.move_filepaths_to_upload_folder(study.id, filepaths)
576+
# If the artifact doesn't have parents and study is not None (is an
577+
# analysis), we move the files to the uploads folder. We also need
578+
# to nullify the column in the prep template table
579+
if not instance.parents and study is not None:
580+
qdb.util.move_filepaths_to_upload_folder(
581+
study.id, filepaths)
581582

582583
sql = """UPDATE qiita.prep_template
583584
SET artifact_id = NULL

qiita_db/test/test_artifact.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,9 @@ def test_create_root_analysis(self):
721721
self.assertIsNone(obs.study)
722722
self.assertEqual(obs.analysis, qdb.analysis.Analysis(1))
723723

724+
# testing that it can be deleted
725+
qdb.artifact.Artifact.delete(obs.id)
726+
724727
def test_create_processed(self):
725728
exp_params = qdb.software.Parameters.from_default_params(
726729
qdb.software.DefaultParameters(1), {'input_data': 1})

0 commit comments

Comments
 (0)