From 03e723b1af0f45b220c88992dff73a0f3aaaa033 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Fri, 26 Jun 2020 01:55:21 +0200 Subject: [PATCH] fix crash when scanner wants to remove the same file more than once A file can be flagged for multiple problems (i.e. multiple unknown maven repos in one build.gradle file that is included in a scandelete path). The scanner will try to delete it once for every problem detected, we don't really care, as long as the file is gone. fixes fdroid/fdroidserver#759 --- fdroidserver/scanner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index 7e589e45..7474e87a 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -188,7 +188,13 @@ def scan_source(build_dir, build=metadata.Build()): logging.info(msg) if json_per_build is not None: json_per_build['infos'].append([msg, path_in_build_dir]) - os.remove(filepath) + try: + os.remove(filepath) + except FileNotFoundError: + # File is already gone, nothing to do. + # This can happen if we find multiple problems in one file that is setup for scandelete + # I.e. build.gradle files containig multiple unknown maven repos. + pass return 0 def warnproblem(what, path_in_build_dir):