From e22d7d2fc90922125f162e5bb11fb2abed92eb59 Mon Sep 17 00:00:00 2001 From: Andrew Senetar Date: Sat, 28 Aug 2021 18:09:10 -0500 Subject: [PATCH] Remove filtering of 0 size files in engine Files size is already able to be filtered at a higher level, some users may decide to see zero length files. Fix #321. --- core/engine.py | 7 +++++-- core/tests/engine_test.py | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/engine.py b/core/engine.py index da52cfac..4c2eadf1 100644 --- a/core/engine.py +++ b/core/engine.py @@ -288,8 +288,7 @@ def getmatches_by_contents(files, bigsize=0, j=job.nulljob): """ size2files = defaultdict(set) for f in files: - if f.size: - size2files[f.size].add(f) + size2files[f.size].add(f) del files possible_matches = [files for files in size2files.values() if len(files) > 1] del size2files @@ -300,6 +299,10 @@ def getmatches_by_contents(files, bigsize=0, j=job.nulljob): for first, second in itertools.combinations(group, 2): if first.is_ref and second.is_ref: continue # Don't spend time comparing two ref pics together. + if first.size == 0 and second.size == 0: + # skip md5 for zero length files + result.append(Match(first, second, 100)) + continue if first.md5partial == second.md5partial: if bigsize > 0 and first.size > bigsize: if first.md5samples == second.md5samples: diff --git a/core/tests/engine_test.py b/core/tests/engine_test.py index 1d809513..cc1ea532 100644 --- a/core/tests/engine_test.py +++ b/core/tests/engine_test.py @@ -530,10 +530,6 @@ class TestCaseGetMatches: class TestCaseGetMatchesByContents: - def test_dont_compare_empty_files(self): - o1, o2 = no(size=0), no(size=0) - assert not getmatches_by_contents([o1, o2]) - def test_big_file_partial_hashes(self): smallsize = 1 bigsize = 100 * 1024 * 1024 # 100MB