19 lines
838 B
Python
19 lines
838 B
Python
import json,pathlib,subprocess,hashlib,time
|
|
base=pathlib.Path(__file__).parent
|
|
m=json.loads((base/'source.json').read_text())
|
|
status={'started':time.time(),'files':[]}
|
|
def save(): (base/'download-status.json').write_text(json.dumps(status,indent=2))
|
|
save()
|
|
for f in m['files']:
|
|
p=base/pathlib.Path(f['path']).name
|
|
partial=p.with_suffix('.gguf.part')
|
|
if not p.exists():
|
|
subprocess.run(['curl','-fL','--retry','8','--retry-delay','5','-C','-','-o',str(partial),f['url']],check=True)
|
|
partial.rename(p)
|
|
h=hashlib.sha256()
|
|
with p.open('rb') as stream:
|
|
while chunk:=stream.read(16*1024*1024):h.update(chunk)
|
|
actual=h.hexdigest();assert actual==f['sha256'] and p.stat().st_size==f['size'], 'Checksum/size mismatch'
|
|
status['files'].append({'name':p.name,'sha256':actual,'verified':True});save()
|
|
status['finished']=time.time();save()
|