From c45617c35f58513585d5273e4129c9d268221e29 Mon Sep 17 00:00:00 2001 From: seamus tuohy Date: Sat, 27 Jul 2019 12:15:04 -0400 Subject: [PATCH] Don't mark empty files as dangerous. This commit stops filecheck from marking empty files as dangerous. The current code sees the MIMETYPE difference between None and the expected mimetype as dangerous. But, empty files are just empty, not dangerous. --- filecheck/filecheck.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/filecheck/filecheck.py b/filecheck/filecheck.py index 492f2d5..1fd8450 100644 --- a/filecheck/filecheck.py +++ b/filecheck/filecheck.py @@ -192,9 +192,11 @@ class File(FileBase): expected_mimetypes = [expected_mimetype] if expected_mimetype in Config.aliases: expected_mimetypes.append(Config.aliases[expected_mimetype]) + if (encoding is None) and (os.path.getsize(self.src_path) == 0): + is_empty_file = True is_known_extension = self.extension in mimetypes.types_map.keys() - if is_known_extension and self.mimetype not in expected_mimetypes: + if is_known_extension and self.mimetype not in expected_mimetypes and not is_empty_file: self.make_dangerous('Mimetype does not match expected mimetypes ({}) for this extension'.format(expected_mimetypes)) def _check_mimetype(self):