Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,12 @@ def delete(cls, artifact_id):
WHERE artifact_id = %s"""
qdb.sql_connection.TRN.add(sql, [artifact_id])

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

sql = """UPDATE qiita.prep_template
SET artifact_id = NULL
Expand Down
3 changes: 3 additions & 0 deletions qiita_db/test/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,9 @@ def test_create_root_analysis(self):
self.assertIsNone(obs.study)
self.assertEqual(obs.analysis, qdb.analysis.Analysis(1))

# testing that it can be deleted
qdb.artifact.Artifact.delete(obs.id)

def test_create_processed(self):
exp_params = qdb.software.Parameters.from_default_params(
qdb.software.DefaultParameters(1), {'input_data': 1})
Expand Down