Skip to content

Commit 3192f90

Browse files
committed
Also use sha1 in directory cache
1 parent 8e871ec commit 3192f90

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

pygccxml/parser/directory_cache.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ class directory_cache_t (declarations_cache.cache_base_t):
6868
modified since the last run).
6969
"""
7070

71-
def __init__(self, dir="cache", compression=False, md5_sigs=True):
71+
def __init__(self, dir="cache", compression=False, sha1_sigs=True):
7272
"""
7373
:param dir: cache directory path, it is created, if it does not exist
7474
7575
:param compression: if `True`, the cache files will be compressed
7676
using `gzip`
7777
78-
:param md5_sigs: `md5_sigs` determines whether file modifications is
79-
checked by computing a `md5` digest or by checking
78+
:param sha1_sigs: `sha1_sigs` determines whether file modifications is
79+
checked by computing a `sha1` digest or by checking
8080
the modification date
8181
"""
8282

@@ -88,13 +88,13 @@ def __init__(self, dir="cache", compression=False, md5_sigs=True):
8888
# Flag that determines whether the cache files will be compressed
8989
self.__compression = compression
9090

91-
# Flag that determines whether the signature is a md5 digest or
91+
# Flag that determines whether the signature is a sha1 digest or
9292
# the modification time
9393
# (this flag is passed to the filename_repository_t class)
94-
self.__md5_sigs = md5_sigs
94+
self.__sha1_sigs = sha1_sigs
9595

9696
# Filename repository
97-
self.__filename_rep = filename_repository_t(self.__md5_sigs)
97+
self.__filename_rep = filename_repository_t(self.__sha1_sigs)
9898

9999
# Index dictionary (Key is the value returned by _create_cache_key()
100100
# (which is based on the header file name) and value is an
@@ -228,15 +228,15 @@ def _load(self):
228228
data = self._read_file(indexfilename)
229229
self.__index = data[0]
230230
self.__filename_rep = data[1]
231-
if self.__filename_rep._md5_sigs != self.__md5_sigs:
231+
if self.__filename_rep._sha1_sigs != self.__sha1_sigs:
232232
print((
233-
"CACHE: Warning: md5_sigs stored in the cache is set " +
234-
"to %s.") % self.__filename_rep._md5_sigs)
233+
"CACHE: Warning: sha1_sigs stored in the cache is set " +
234+
"to %s.") % self.__filename_rep._sha1_sigs)
235235
print("Please remove the cache to change this setting.")
236-
self.__md5_sigs = self.__filename_rep._md5_sigs
236+
self.__sha1_sigs = self.__filename_rep._sha1_sigs
237237
else:
238238
self.__index = {}
239-
self.__filename_rep = filename_repository_t(self.__md5_sigs)
239+
self.__filename_rep = filename_repository_t(self.__sha1_sigs)
240240

241241
self.__modified_flag = False
242242

@@ -355,15 +355,15 @@ def _create_config_signature(self, config):
355355
"""
356356
return the signature for a config object.
357357
358-
The signature is computed as md5 digest of the contents of
358+
The signature is computed as sha1 digest of the contents of
359359
working_directory, include_paths, define_symbols and
360360
undefine_symbols.
361361
362362
:param config: Configuration object
363363
:type config: :class:`parser.xml_generator_configuration_t`
364364
:rtype: str
365365
"""
366-
m = hashlib.md5()
366+
m = hashlib.sha1()
367367
m.update(config.working_directory)
368368
for p in config.include_paths:
369369
m.update(p)
@@ -436,14 +436,14 @@ class filename_repository_t:
436436
called so that the entry can be removed from the repository.
437437
"""
438438

439-
def __init__(self, md5_sigs):
439+
def __init__(self, sha1_sigs):
440440
"""Constructor.
441441
"""
442442

443-
# Flag that determines whether the signature is a md5 digest or
443+
# Flag that determines whether the signature is a sha1 digest or
444444
# the modification time
445445
# (this flag is passed to the filename_repository_t class)
446-
self._md5_sigs = md5_sigs
446+
self._sha1_sigs = sha1_sigs
447447

448448
# ID lookup table (key: filename / value: id_)
449449
self.__id_lut = {}
@@ -524,18 +524,18 @@ def _get_signature(self, entry):
524524
"""Return the signature of the file stored in entry.
525525
"""
526526

527-
if self._md5_sigs:
528-
# return md5 digest of the file content...
527+
if self._sha1_sigs:
528+
# return sha1 digest of the file content...
529529
if not os.path.exists(entry.filename):
530530
return None
531531
try:
532532
f = open(entry.filename)
533533
except IOError as e:
534-
print("Cannot determine md5 digest:", e)
534+
print("Cannot determine sha1 digest:", e)
535535
return None
536536
data = f.read()
537537
f.close()
538-
return hashlib.md5(data).digest()
538+
return hashlib.sha1(data).digest()
539539
else:
540540
# return file modification date...
541541
try:

0 commit comments

Comments
 (0)