Skip to content

Commit

Permalink
Verify sha before cache write
Browse files Browse the repository at this point in the history
  • Loading branch information
vondele committed Jul 7, 2024
1 parent 12981ff commit 8bd324e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def download_net(remote, testing_dir, net, global_cache):
url = remote + "/api/nn/" + net
print("Downloading {}".format(net))
content = requests_get(url, allow_redirects=True, timeout=HTTP_TIMEOUT).content
cache_write(global_cache, net, content)
hash = hashlib.sha256(content).hexdigest()
if hash[:12] == net[3:15]:
cache_write(global_cache, net, content)
else:
print("Using {} from global cache".format(net))

Expand Down

0 comments on commit 8bd324e

Please sign in to comment.