On Sun, May 19, 2013 at 07:37:44PM +0800, Michael Deegan wrote: > Package: apt-cacher > Version: 1.7.6 > Severity: normal > > Dear Maintainer, > > It appears that when an InRelease file disappears (as seems to have > happened to wheezy following its release), apt-cacher returns the old file > instead, albeit with the 404 message body overwriting the beginning of the > file:
Thanks > A glance at the code around line 770 suggests that all errors result in the > cached file being returned (and an 'OFFLINE' status). I'm not convinced > that this is a good idea, at least with 404s. :P Yes, agreed. This should only apply to Server errors. Try this patch: commit 04ec71dd2367d88ac093f18ac36f59c52f55887f Author: Mark Hindley <m...@hindley.org.uk> Date: Mon May 20 15:19:07 2013 +0100 Reorder handling of If-Modified request response. Client errors also count as EXPIRED diff --git a/apt-cacher b/apt-cacher index 3626738..0ca995b 100755 --- a/apt-cacher +++ b/apt-cacher @@ -758,19 +758,20 @@ sub handle_connection { $ifmod_request->header('If-Modified-Since' => $since); $response = fetch_store($ifmod_request, $cache); $cfg->{debug} && debug_message('Got '.$response->code); - if ($response->code == 200) { - $cache->{status} = 'EXPIRED'; - $cfg->{debug} && debug_message($cache->{status}); - } - elsif ($response->code == 304) { + if ($response->code == 304) { # Update cached Date and Client-Date headers $cached_response->date($response->date || time); write_header($cache->{header}, $cached_response); } - elsif ($response->is_error) { + elsif ($response->is_server_error) { # Offline, used cached $cache->{status} = 'OFFLINE'; } + else { # Success or client error + $cache->{status} = 'EXPIRED'; + $cfg->{debug} && debug_message($cache->{status}); + } + } # Still don't know what to do? # use HTTP timestamping/ETag > I suspect the returned cached file being contaminated by the 404 response > body is a separate bug... Yes. After the above patch, it is hidden again, but this addresses it: commit 9c9ba9c10624fd65dcd3fbc219514822e4a2eab1 Author: Mark Hindley <m...@hindley.org.uk> Date: Mon May 20 15:10:38 2013 +0100 Only write body to cache for success (200) diff --git a/apt-cacher b/apt-cacher index ca5f64a..3626738 100755 --- a/apt-cacher +++ b/apt-cacher @@ -1767,7 +1767,7 @@ sub libcurl { elsif ($curl_request->method eq 'POST') { $response->add_content($_); } - elsif ($cache->{content}) { + elsif ($response->is_success && $cache->{content}) { print({$cache->{content}} $_) || do { # Don't use die to avoid invoking die handler info_message "Warning: print failed: $!"; Does that help? Mark -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org