Bug#777565: Non-existing (404) files confuse size tracking
Paul Menzel wrote:
> As you can see, there is no InRelease file in the archive and a 404
> error page is returned which has the size of 168 bytes. For whatever
> reason, APT than thinks that this is the size of `Release.gpg`, which is
> incorrect.
Hi,
I can easily reproduce this bug as well with an HTTPS repository that
lacks an InRelease file. Looking at the Debug::pkgAcquire::Worker
output, I think this is due to not zeroing the FetchResult object when
HttpsMethod::Fetch() encounters a 404. The 'Size' field (i.e., the size
of the server's 404 response) then persists into the next fetch.
The attached patch should prevent this from happening.
--
Robert Edmonds
edmonds@debian.org
>From 5b729cc5272d2fbd2fae1dff6b4ff4c4557ff91b Mon Sep 17 00:00:00 2001
From: Robert Edmonds <edmonds@debian.org>
Date: Sun, 22 Mar 2015 00:12:45 -0400
Subject: [PATCH] HttpsMethod::Fetch(): Zero the FetchResult object when
leaving due to 404
---
methods/https.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/methods/https.cc b/methods/https.cc
index 3a5981b..f2b00dd 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -402,6 +402,8 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
_error->Error("%s", err);
// unlink, no need keep 401/404 page content in partial/
unlink(File->Name().c_str());
+ Res.Size = 0;
+ Res.LastModified = 0;
return false;
}
--
2.1.4
Reply to: