From 011e844d4d708ff31477dffac20c6eaaa7e40191 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 25 Feb 2020 13:10:25 -0800 Subject: [PATCH] Compare os.path.getsize before even opening handles. --- voussoirkit/quickid.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/voussoirkit/quickid.py b/voussoirkit/quickid.py index 280d4fd..c758fd4 100644 --- a/voussoirkit/quickid.py +++ b/voussoirkit/quickid.py @@ -25,6 +25,8 @@ def equal_handle(handle1, handle2, *args, **kwargs): def equal_file(filename1, filename2, *args, **kwargs): filename1 = os.path.abspath(filename1) filename2 = os.path.abspath(filename2) + if os.path.getsize(filename1) != os.path.getsize(filename2): + return False with open(filename1, 'rb') as handle1, open(filename2, 'rb') as handle2: return equal_handle(handle1, handle2, *args, **kwargs)