From 7dcc8c48da7587da9f141b2f73e82d3955fed65f Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 29 Oct 2019 14:35:23 +0100 Subject: [PATCH] Also delete corpus files when a corpus gets deleted --- app/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index e68d0682..2abecee2 100644 --- a/app/utils.py +++ b/app/utils.py @@ -63,5 +63,7 @@ def background_delete_corpus(app, corpus_id): logger.warning('Called by delete_thread.') logger.warning('Corpus id is: {}.'.format(corpus_id)) corpus = Corpus.query.filter_by(id=corpus_id).first() - logger.warning('Corpus object is: {}'.format(corpus)) + for corpus_file in corpus.files: + db.session.delete(corpus_file) + logger.warning('Corpus object is: {}'.format(corpus)) corpus.delete_corpus()