mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
utils: use dict_md5
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+2
-4
@@ -5,7 +5,7 @@ import threading
|
||||
|
||||
from dvc.system import System
|
||||
from dvc.output import Output
|
||||
from dvc.utils import file_md5, bytes_md5
|
||||
from dvc.utils import file_md5, dict_md5
|
||||
from dvc.exceptions import DvcException
|
||||
|
||||
|
||||
@@ -70,9 +70,7 @@ class State(object):
|
||||
def compute_md5(self, path):
|
||||
if os.path.isdir(path):
|
||||
dir_info = self.collect_dir(path)
|
||||
byts = json.dumps(dir_info, sort_keys=True).encode('utf-8')
|
||||
md5 = bytes_md5(byts)
|
||||
return md5 + Output.MD5_DIR_SUFFIX
|
||||
return dict_md5(dir_info) + Output.MD5_DIR_SUFFIX
|
||||
else:
|
||||
return file_md5(path)[0]
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Helpers for other modules.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import stat
|
||||
import shutil
|
||||
import hashlib
|
||||
@@ -34,6 +35,11 @@ def bytes_md5(byts):
|
||||
return hasher.hexdigest()
|
||||
|
||||
|
||||
def dict_md5(d):
|
||||
byts = json.dumps(d, sort_keys=True).encode('utf-8')
|
||||
return bytes_md5(byts)
|
||||
|
||||
|
||||
def cached_property(func):
|
||||
'''A decorator for caching properties in classes.'''
|
||||
def get(self):
|
||||
|
||||
Reference in New Issue
Block a user