From 58709ebca01940b57527664adf6ad0309d6dd980 Mon Sep 17 00:00:00 2001 From: Jan Friedli Date: Sun, 30 Aug 2020 14:44:41 +0200 Subject: added more logging for the helpers and the frontend --- matweb/frontend.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'matweb/frontend.py') diff --git a/matweb/frontend.py b/matweb/frontend.py index 8295f4e..48e4c19 100644 --- a/matweb/frontend.py +++ b/matweb/frontend.py @@ -27,8 +27,10 @@ def download_file(key: str, secret: str, filename: str): file_removal_scheduler.run_file_removal_job(current_app.config['UPLOAD_FOLDER']) if not os.path.exists(complete_path): + current_app.logger.error('Non existing file requested') return redirect(url_for('routes.upload_file')) if hmac.compare_digest(utils.hash_file(complete_path, secret), key) is False: + current_app.logger.error('Non matching digest for file') return redirect(url_for('routes.upload_file')) @after_this_request @@ -47,28 +49,33 @@ def upload_file(): if request.method == 'POST': if 'file' not in request.files: # check if the post request has the file part flash('No file part') + current_app.logger.error('Missing file part in upload') return redirect(request.url) uploaded_file = request.files['file'] if not uploaded_file.filename: flash('No selected file') + current_app.logger.error('Missing filename in upload') return redirect(request.url) try: filename, filepath = utils.save_file(uploaded_file, current_app.config['UPLOAD_FOLDER']) except ValueError: flash('Invalid Filename') + current_app.logger.error('Invalid Filename in upload') return redirect(request.url) parser, mime = utils.get_file_parser(filepath) if parser is None: flash('The type %s is not supported' % mime) + current_app.logger.error('Unsupported type %s', mime) return redirect(url_for('routes.upload_file')) meta = parser.get_meta() if parser.remove_all() is not True: flash('Unable to clean %s' % mime) + current_app.logger.error('Unable to clean %s', mime) return redirect(url_for('routes.upload_file')) key, secret, meta_after, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER']) -- cgit v1.3