From 29f1be5c805f5427cd7f1503b013c1183e3a3bfe Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 21 Apr 2020 10:27:42 +0200 Subject: [PATCH] Delete functions should not throw an error, if the ressource does not exists. -> Consider it as deleted if does not exist --- app/corpora/background_functions.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/corpora/background_functions.py b/app/corpora/background_functions.py index 1b8f7fc0..55d9af6b 100644 --- a/app/corpora/background_functions.py +++ b/app/corpora/background_functions.py @@ -5,16 +5,20 @@ def delete_corpus_(app, corpus_id): with app.app_context(): corpus = Corpus.query.get(corpus_id) if corpus is None: - raise Exception('Corpus {} not found!'.format(corpus_id)) - corpus.delete() + # raise Exception('Corpus {} not found!'.format(corpus_id)) + pass + else: + corpus.delete() def delete_corpus_file_(app, corpus_file_id): with app.app_context(): corpus_file = CorpusFile.query.get(corpus_file_id) if corpus_file is None: - raise Exception('Corpus file {} not found!'.format(corpus_file_id)) - corpus_file.delete() + # raise Exception('Corpus file {} not found!'.format(corpus_file_id)) + pass + else: + corpus_file.delete() def edit_corpus_file_(app, corpus_file_id): @@ -22,4 +26,5 @@ def edit_corpus_file_(app, corpus_file_id): corpus_file = CorpusFile.query.get(corpus_file_id) if corpus_file is None: raise Exception('Corpus file {} not found!'.format(corpus_file_id)) - corpus_file.insert_metadata() + else: + corpus_file.insert_metadata()