caching_proxy.py: only take .deb and by-hash artifacts from the old path

This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-03-05 15:25:42 +01:00
parent db2be70f88
commit 1ffa32f590
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -46,7 +46,12 @@ class ProxyRequestHandler(http.server.BaseHTTPRequestHandler):
newpath = pathlib.Path("/dev/null") newpath = pathlib.Path("/dev/null")
# copy from oldpath to newpath and send back to client # copy from oldpath to newpath and send back to client
if oldpath.exists(): # Only take files from the old cache if they are .deb files or Packages
# files in the by-hash directory as only those are unique by their path
# name. Other files like InRelease files have to be downloaded afresh.
if oldpath.exists() and (
oldpath.suffix == ".deb" or "by-hash" in oldpath.parts
):
print(f"proxy cached: {self.path}", file=sys.stderr) print(f"proxy cached: {self.path}", file=sys.stderr)
self.wfile.write(b"HTTP/1.1 200 OK\r\n") self.wfile.write(b"HTTP/1.1 200 OK\r\n")
self.send_header("Content-Length", oldpath.stat().st_size) self.send_header("Content-Length", oldpath.stat().st_size)