Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19a7c5b

Browse files
committed
tests: do not read whole file at once for digest. Iterate instead.
1 parent7eab6e3 commit19a7c5b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎tests/helpers/ptrack_helpers.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,9 +1774,9 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
17741774
file_relpath=os.path.relpath(file_fullpath,pgdata)
17751775
directory_dict['files'][file_relpath]= {'is_datafile':False}
17761776
withopen(file_fullpath,'rb')asf:
1777-
content=f.read()
17781777
# truncate cfm's content's zero tail
17791778
iffile_relpath.endswith('.cfm'):
1779+
content=f.read()
17801780
zero64=b"\x00"*64
17811781
l=len(content)
17821782
whilel>64:
@@ -1785,9 +1785,14 @@ def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
17851785
break
17861786
l=s
17871787
content=content[:l]
1788-
directory_dict['files'][file_relpath]['md5']=hashlib.md5(content).hexdigest()
1789-
# directory_dict['files'][file_relpath]['md5'] = hashlib.md5(
1790-
# f = open(file_fullpath, 'rb').read()).hexdigest()
1788+
digest=hashlib.md5(content)
1789+
else:
1790+
digest=hashlib.md5()
1791+
whileTrue:
1792+
b=f.read(64*1024)
1793+
ifnotb:break
1794+
digest.update(b)
1795+
directory_dict['files'][file_relpath]['md5']=digest.hexdigest()
17911796

17921797
# crappy algorithm
17931798
iffile.isdigit():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp