Also delete corpus files when a corpus gets deleted

This commit is contained in:
Patrick Jentsch 2019-10-29 14:35:23 +01:00
parent 0a8f6a5a44
commit 7dcc8c48da

View File

@ -63,5 +63,7 @@ def background_delete_corpus(app, corpus_id):
logger.warning('Called by delete_thread.') logger.warning('Called by delete_thread.')
logger.warning('Corpus id is: {}.'.format(corpus_id)) logger.warning('Corpus id is: {}.'.format(corpus_id))
corpus = Corpus.query.filter_by(id=corpus_id).first() corpus = Corpus.query.filter_by(id=corpus_id).first()
for corpus_file in corpus.files:
db.session.delete(corpus_file)
logger.warning('Corpus object is: {}'.format(corpus)) logger.warning('Corpus object is: {}'.format(corpus))
corpus.delete_corpus() corpus.delete_corpus()