#!/usr/bin/env python3
import hashlib
import json
from pathlib import Path
root=Path(__file__).parent/'private-evidence';assert not(root/'manifest.json').exists()
files=[]
for file in sorted(root.rglob('*')):
 if file.is_file():
  assert file.stat().st_mode&0o077==0
  files.append({'path':file.relative_to(root).as_posix(),'bytes':file.stat().st_size,'sha256':hashlib.sha256(file.read_bytes()).hexdigest()})
manifest=root/'manifest.json';manifest.write_text(json.dumps({'files':files},ensure_ascii=False,indent=2)+'\n');manifest.chmod(0o600)
print(json.dumps({'files':len(files),'manifest_sha256':hashlib.sha256(manifest.read_bytes()).hexdigest()}))
