From 7bfb0a8088c70b2d75a51287202dc0042f53151d Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <antoine.romain.dumont@gmail.com>
Date: Mon, 17 Sep 2018 11:28:13 +0200
Subject: [PATCH] swh.model.hashutil: Reuse hash_path's old definition

Remove unused track_length parameter
---
 swh/model/hashutil.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/swh/model/hashutil.py b/swh/model/hashutil.py
index ee29b6e6..df73142a 100644
--- a/swh/model/hashutil.py
+++ b/swh/model/hashutil.py
@@ -294,8 +294,7 @@ def hash_file(fobj, length=None, algorithms=DEFAULT_ALGORITHMS,
     return h.digest()
 
 
-def hash_path(path, algorithms=DEFAULT_ALGORITHMS, chunk_cb=None,
-              track_length=True):
+def hash_path(path, algorithms=DEFAULT_ALGORITHMS, chunk_cb=None):
     """(deprecated) cf. MultiHash.from_path
 
     Hash the contents of the file at the given path with the given
@@ -319,11 +318,11 @@ def hash_path(path, algorithms=DEFAULT_ALGORITHMS, chunk_cb=None,
         OSError on file access error
 
     """
-    if track_length:
-        algorithms = set(['length']).union(algorithms)
     length = os.path.getsize(path)
     with open(path, 'rb') as fobj:
-        return hash_file(fobj, length, algorithms, chunk_cb=chunk_cb)
+        hashes = hash_file(fobj, length, algorithms, chunk_cb=chunk_cb)
+    hashes['length'] = length
+    return hashes
 
 
 def hash_data(data, algorithms=DEFAULT_ALGORITHMS):
-- 
GitLab