commit:     ccebae2e51cbbd03a30d5e3599ee82f974643fd2
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 14 08:15:21 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 14 09:33:03 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ccebae2e

bintree: Prefer 'Last-Modified' over 'timestamp' header

The Last-Modified header is a standard header and seems to be more in
sync accross different mirrors than 'timestamp'. Prefer it over
'timestamp'.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Part-of: https://github.com/gentoo/portage/pull/1466
Closes: https://github.com/gentoo/portage/pull/1466
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                         | 5 ++++-
 lib/portage/dbapi/bintree.py | 6 +++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 71edb962fa..04e47696d4 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,10 @@ Release notes take the form of the following optional 
categories:
 portage-3.0.70 (UNRELEASED)
 --------------
 
-TODO
+Features
+
+* Prefer the 'Last-Modified' over the 'timestamp' HTTP header when
+  querying binhosts.
 
 portage-3.0.69 (2025-09-14)
 --------------

diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index 2fdb08d44b..8e69fe3b89 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -1466,13 +1466,13 @@ class binarytree:
                                     proxies=proxies,
                                 )
                                 if hasattr(f, "headers"):
-                                    if f.headers.get("timestamp", ""):
-                                        remote_timestamp = 
f.headers.get("timestamp")
-                                    elif f.headers.get("Last-Modified", ""):
+                                    if f.headers.get("Last-Modified", ""):
                                         last_modified = 
f.headers.get("Last-Modified")
                                         remote_timestamp = http_to_timestamp(
                                             last_modified
                                         )
+                                    elif f.headers.get("timestamp", ""):
+                                        remote_timestamp = 
f.headers.get("timestamp")
                                 if (
                                     remote_timestamp
                                     and local_timestamp

Reply via email to