2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-25 02:35:04 +01:00

evil bug in md5_tstamp

This commit is contained in:
Thomas Nagy 2011-10-18 19:02:53 +02:00
parent 1f4edf5ace
commit bc001ce1de

View File

@ -20,11 +20,11 @@ from waflib import Utils, Build, Context
STRONGEST = True STRONGEST = True
Context.DBFILE += '_md5tstamp' Context.DBFILE += '_md5tstamp'
Build.hash_cache = {} Build.hashes_md5_tstamp = {}
Build.SAVED_ATTRS.append('hash_cache') Build.SAVED_ATTRS.append('hashes_md5_tstamp')
def store(self): def store(self):
# save the hash cache as part of the default pickle file # save the hash cache as part of the default pickle file
self.hash_cache = Build.hash_cache self.hashes_md5_tstamp = Build.hashes_md5_tstamp
self.store_real() self.store_real()
Build.BuildContext.store_real = Build.BuildContext.store Build.BuildContext.store_real = Build.BuildContext.store
Build.BuildContext.store = store Build.BuildContext.store = store
@ -33,9 +33,9 @@ def restore(self):
# we need a module variable for h_file below # we need a module variable for h_file below
self.restore_real() self.restore_real()
try: try:
Build.hash_cache = self.hash_cache or {} Build.hashes_md5_tstamp = self.hashes_md5_tstamp or {}
except Exception as e: except Exception as e:
Build.hash_cache = {} Build.hashes_md5_tstamp = {}
Build.BuildContext.restore_real = Build.BuildContext.restore Build.BuildContext.restore_real = Build.BuildContext.restore
Build.BuildContext.restore = restore Build.BuildContext.restore = restore
@ -43,9 +43,9 @@ def h_file(filename):
st = os.stat(filename) st = os.stat(filename)
if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file') if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
if filename in Build.hash_cache: if filename in Build.hashes_md5_tstamp:
if Build.hash_cache[filename][0] == str(st.st_mtime): if Build.hashes_md5_tstamp[filename][0] == str(st.st_mtime):
return Build.hash_cache[filename][1] return Build.hashes_md5_tstamp[filename][1]
m = Utils.md5() m = Utils.md5()
if STRONGEST: if STRONGEST:
@ -63,7 +63,7 @@ def h_file(filename):
m.update(filename) m.update(filename)
# ensure that the cache is overwritten # ensure that the cache is overwritten
Build.hash_cache[filename] = (str(st.st_mtime), m.digest()) Build.hashes_md5_tstamp[filename] = (str(st.st_mtime), m.digest())
return m.digest() return m.digest()
Utils.h_file = h_file Utils.h_file = h_file