Code Repositories xandikos / 3cd161b
Use md5sum rather than timestamp. Jelmer Vernooń≥ 1 year, 3 months ago
1 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2222 """
2323
2424 import errno
25 import hashlib
2526 import logging
2627 import os
2728 import shutil
6869
6970 def _get_etag(self, name):
7071 path = os.path.join(self.path, name)
71 try:
72 st = os.stat(path)
72 md5 = hashlib.md5()
73 try:
74 with open(path, 'rb') as f:
75 for chunk in f:
76 md5.update(chunk)
7377 except IOError as e:
7478 if e.errno == errno.ENOENT:
7579 raise KeyError
7680 raise
77 mtime = getattr(st, 'st_mtime_ns', None)
78 if mtime is None:
79 mtime = st.st_mtime
80 return '{:.9f}'.format(mtime)
81 return md5.hexdigest()
8182
8283 def _get_raw(self, name, etag=None):
8384 """Get the raw contents of an object.