Compare os.path.getsize before even opening handles.
This commit is contained in:
parent
64bcb8167c
commit
011e844d4d
1 changed files with 2 additions and 0 deletions
|
@ -25,6 +25,8 @@ def equal_handle(handle1, handle2, *args, **kwargs):
|
||||||
def equal_file(filename1, filename2, *args, **kwargs):
|
def equal_file(filename1, filename2, *args, **kwargs):
|
||||||
filename1 = os.path.abspath(filename1)
|
filename1 = os.path.abspath(filename1)
|
||||||
filename2 = os.path.abspath(filename2)
|
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:
|
with open(filename1, 'rb') as handle1, open(filename2, 'rb') as handle2:
|
||||||
return equal_handle(handle1, handle2, *args, **kwargs)
|
return equal_handle(handle1, handle2, *args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue