@@ -1725,9 +1725,9 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
1725
1725
file_relpath = os .path .relpath (file_fullpath , pgdata )
1726
1726
directory_dict ['files' ][file_relpath ] = {'is_datafile' : False }
1727
1727
with open (file_fullpath , 'rb' ) as f :
1728
- content = f .read ()
1729
1728
# truncate cfm's content's zero tail
1730
1729
if file_relpath .endswith ('.cfm' ):
1730
+ content = f .read ()
1731
1731
zero64 = b"\x00 " * 64
1732
1732
l = len (content )
1733
1733
while l > 64 :
@@ -1736,9 +1736,14 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
1736
1736
break
1737
1737
l = s
1738
1738
content = content [:l ]
1739
- directory_dict ['files' ][file_relpath ]['md5' ] = hashlib .md5 (content ).hexdigest ()
1740
- # directory_dict['files'][file_relpath]['md5'] = hashlib.md5(
1741
- # f = open(file_fullpath, 'rb').read()).hexdigest()
1739
+ digest = hashlib .md5 (content )
1740
+ else :
1741
+ digest = hashlib .md5 ()
1742
+ while True :
1743
+ b = f .read (64 * 1024 )
1744
+ if not b : break
1745
+ digest .update (b )
1746
+ directory_dict ['files' ][file_relpath ]['md5' ] = digest .hexdigest ()
1742
1747
1743
1748
# crappy algorithm
1744
1749
if file .isdigit ():
@@ -1750,7 +1755,7 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
1750
1755
)
1751
1756
1752
1757
for root , dirs , files in os .walk (pgdata , topdown = False , followlinks = True ):
1753
- for directory in dirs :
1758
+ for directory in sorted ( dirs ) :
1754
1759
directory_path = os .path .join (root , directory )
1755
1760
directory_relpath = os .path .relpath (directory_path , pgdata )
1756
1761
0 commit comments