File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,14 @@ def mkdir_with_dot_tmp(folder: Path)->Tuple[Path, Path]:
99
99
tmpdir .mkdir (parents = True , exist_ok = True )
100
100
return (folder , tmpdir )
101
101
102
+ def CalcFileSha256 (filname ):
103
+ ''' calculate file sha256 '''
104
+ with open (filname , "rb" ) as f :
105
+ sha256obj = hashlib .sha256 ()
106
+ sha256obj .update (f .read ())
107
+ hash_value = sha256obj .hexdigest ()
108
+ return hash_value
109
+
102
110
def move_files_in (src : Path , dst : Path ):
103
111
empty = True
104
112
for file in src .glob ('*' ):
@@ -237,8 +245,8 @@ def collect_tmp_dir():
237
245
dest_dir .mkdir (parents = True , exist_ok = True )
238
246
if dest_filename .suffix == '.deb' :
239
247
deb_set [str (dest_filename .relative_to (dest_base_dir ))] = pkg_size
240
- if dest_filename .is_file () and dest_filename .stat ().st_size == pkg_size :
241
- print (f"Skipping { pkg_filename } , size { pkg_size } " )
248
+ if dest_filename .is_file () and ( dest_filename .stat ().st_size == pkg_size and CalcFileSha256 ( dest_filename ) == pkg_checksum ) :
249
+ print (f"Skipping { pkg_filename } , size { pkg_size } , sha256 { pkg_checksum } " )
242
250
continue
243
251
244
252
pkg_url = f"{ base_url } /{ pkg_filename } "
You can’t perform that action at this time.
0 commit comments