from pathlib import Path
import json,subprocess,hashlib,concurrent.futures
base=Path('/tmp/issue-lead-33443-r1/evidence-capture')
m=json.loads((base/'upload-map.json').read_text())
def check(item):
 name,entry=item
 try:
  public=subprocess.check_output(['curl','--fail','--silent','--show-error','--max-time','30',entry['url']])
  local=(base/name).read_bytes()
  return dict(name=name,bytes=len(local),publicBytes=len(public),same=hashlib.sha256(local).digest()==hashlib.sha256(public).digest())
 except Exception as e:return dict(name=name,error=str(e))
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:results=list(pool.map(check,m.items()))
(base/'upload-audit.json').write_text(json.dumps(results,indent=2))
print(json.dumps([x for x in results if not x.get('same')],indent=2));print('Audited',len(results),'files')
