From 1ffa32f5902066824710f23d38f7600119224001 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 5 Mar 2023 15:25:42 +0100 Subject: [PATCH] caching_proxy.py: only take .deb and by-hash artifacts from the old path --- caching_proxy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/caching_proxy.py b/caching_proxy.py index 40053f1..4bc7b9e 100755 --- a/caching_proxy.py +++ b/caching_proxy.py @@ -46,7 +46,12 @@ class ProxyRequestHandler(http.server.BaseHTTPRequestHandler): newpath = pathlib.Path("/dev/null") # 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) self.wfile.write(b"HTTP/1.1 200 OK\r\n") self.send_header("Content-Length", oldpath.stat().st_size)