| @@ -19,6 +19,7 @@ def main(): |
| 19 | 19 | p=argparse.ArgumentParser(description=__doc__) |
| 20 | 20 | p.add_argument('--private-root',type=Path,required=True) |
| 21 | 21 | p.add_argument('--report',type=Path,required=True) |
| 22 | + p.add_argument('--sample',type=int,help='test only this many artifact transfers; never a full-cache result') |
| 22 | 23 | a=p.parse_args();root=a.private_root.resolve();root.mkdir(parents=True,exist_ok=True) |
| 23 | 24 | curl='curl.exe' if os.name=='nt' else 'curl' |
| 24 | 25 | manifest=root/'modules.jsonl.gz' |
| @@ -27,6 +28,9 @@ def main(): |
| 27 | 28 | if sha(manifest)!=MANIFEST_SHA:raise ValueError('cache manifest digest mismatch') |
| 28 | 29 | lines=gzip.decompress(manifest.read_bytes()).splitlines();header=json.loads(lines[0]);rows=[json.loads(l) for l in lines[1:]] |
| 29 | 30 | if len(rows)!=175187 or header['source_tree']!='24df20b62d9976ccd20da819bc20b16f808f0fdd':raise ValueError('unexpected cache inputs') |
| 31 | + if a.sample is not None: |
| 32 | + if not 1<=a.sample<=100:raise ValueError('sample must be 1..100') |
| 33 | + rows=rows[:a.sample] |
| 30 | 34 | directory=root/'artifacts';directory.mkdir(exist_ok=True) |
| 31 | 35 | pending={};verified=0 |
| 32 | 36 | config=root/'download.conf' |
| @@ -35,15 +39,18 @@ def main(): |
| 35 | 39 | if len(artifact)!=21 or not artifact.endswith('.ltar') or any(c not in '0123456789abcdef' for c in artifact[:-5]):raise ValueError('unsafe artifact name') |
| 36 | 40 | target=directory/artifact |
| 37 | 41 | if target.exists() and sha(target)==digest:verified+=1;continue |
| 38 | | - partial=target.with_suffix('.partial');pending[str(partial)]=(target,digest) |
| 42 | + partial=target.with_suffix('.partial') |
| 43 | + if partial.exists() and sha(partial)==digest:partial.replace(target);verified+=1;continue |
| 44 | + pending[str(partial)]=(target,digest) |
| 39 | 45 | cfg.write('url = '+json.dumps(ARTIFACT_URL+artifact[:-5]+'.art')+'\n') |
| 40 | 46 | cfg.write('output = '+json.dumps(str(partial))+'\n') |
| 47 | + cfg.write('write-out = '+json.dumps('%{filename_effective}\n')+'\n') |
| 41 | 48 | cfg.write('fail\nlocation\nsilent\nshow-error\nretry = 4\nretry-all-errors\nmax-time = 120\nnext\n') |
| 42 | 49 | print(f'progress: {verified}/{len(rows)} pinned native cache archives verified',flush=True) |
| 43 | 50 | failures=0;start=time.monotonic() |
| 44 | 51 | if pending: |
| 45 | 52 | with (root/'download-errors.log').open('w') as errors: |
| 46 | | - proc=subprocess.Popen([curl,'--parallel','--parallel-max','64','--config',str(config),'--write-out','%{filename_effective}\\n'],stdout=subprocess.PIPE,stderr=errors,text=True) |
| 53 | + proc=subprocess.Popen([curl,'--parallel','--parallel-max','64','--config',str(config)],stdout=subprocess.PIPE,stderr=errors,text=True) |
| 47 | 54 | for line in proc.stdout: |
| 48 | 55 | key=line.strip();item=pending.pop(key,None) |
| 49 | 56 | if item is None:raise ValueError('unexpected curl output path') |
| @@ -56,8 +63,8 @@ def main(): |
| 56 | 63 | rc=proc.wait() |
| 57 | 64 | if rc or pending or failures:raise RuntimeError(f'incomplete download: verified={verified}, unfinished={len(pending)}, failed={failures}; completed archives retained for resume') |
| 58 | 65 | report={'manifest_url':MANIFEST_URL,'manifest_sha256':MANIFEST_SHA,'modules':len(rows),'verified_artifacts':verified, |
| 59 | | - 'source_tree':header['source_tree'],'scope':'Third-party compiled-cache bytes; not an independent rebuild or a declaration atlas.'} |
| 66 | + 'source_tree':header['source_tree'],'sample_only':a.sample is not None,'scope':'Third-party compiled-cache bytes; not an independent rebuild or a declaration atlas.'} |
| 60 | 67 | a.report.write_text(json.dumps(report,indent=2)+'\n',encoding='utf-8') |
| 61 | | - print('Native cache archive digests verified; no proof verification or declaration extraction performed.',flush=True) |
| 68 | + print(('Sample only: ' if a.sample is not None else '')+'Native cache archive digests verified; no proof verification or declaration extraction performed.',flush=True) |
| 62 | 69 | |
| 63 | 70 | if __name__=='__main__':main() |