def hashsite(sitepath):
hash = hashlib.sha256()
def hashdir(dirpath, is_home):
for entry in os.scandir(dirpath):
if entry.is_file():
if entry.name.endswith('~'):
continue
mtime = os.path.getmtime(entry.path)
hash.update(str(mtime).encode())
hash.update(entry.name.encode())
if entry.is_dir():
if is_home and entry.name == 'out':
continue
hashdir(entry.path, False)
hashdir(sitepath, True)
return hash.digest()
评论列表
文章目录