Skip to content
Snippets Groups Projects
Verified Commit 50e583f2 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

MultiHash.from_path: Use the length coming from os.path

parent 7bfb0a80
No related merge requests found
......@@ -95,11 +95,12 @@ class MultiHash:
track_length=True):
if not length:
length = os.path.getsize(path)
with open(path, 'rb') as f:
ret = cls.from_file(f, hash_names=hash_names, length=length)
# For compatibility reason with `hash_path`
if track_length:
hash_names = hash_names.union(EXTRA_LENGTH)
with open(path, 'rb') as f:
return cls.from_file(f, hash_names=hash_names, length=length)
ret.state['length'] = length
return ret
@classmethod
def from_data(cls, data, hash_names=DEFAULT_ALGORITHMS, length=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment