Skip to content

Commit 628cc25

Browse files
authored
Merge pull request #261 from anarcat/cachestamp
fix apt cache timestamp logic
2 parents 0f5cf5c + 1d4dedb commit 628cc25

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

apt_info.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,20 @@ def _write_autoremove_pending(registry, cache):
9494
def _write_cache_timestamps(registry):
9595
g = Gauge('apt_package_cache_timestamp_seconds', "Apt update last run time.", registry=registry)
9696
apt_pkg.init_config()
97-
if (
98-
apt_pkg.config.find_b("APT::Periodic::Update-Package-Lists") and
99-
os.path.isfile("/var/lib/apt/periodic/update-success-stamp")
100-
):
101-
# if we run updates automatically with APT::Periodic, we can
102-
# check this timestamp file if it exists
97+
if os.path.isfile("/var/lib/apt/periodic/update-success-stamp"):
98+
# this file is often used as a flag file for sucessful runs on
99+
# systems that do not use apt-periodic features, namely
100+
# apt-config-auto-update and the Puppetlabs "apt" puppet
101+
# module.
102+
#
103+
# Example configuration:
104+
#
105+
# APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp";};
103106
stamp_file = "/var/lib/apt/periodic/update-success-stamp"
107+
elif apt_pkg.config.find_b("APT::Periodic::Update-Package-Lists"):
108+
# if we run updates automatically with APT::Periodic, we can
109+
# check this timestamp file
110+
stamp_file = "/var/lib/apt/periodic/update-stamp"
104111
else:
105112
# if not, let's just fallback on the partial file of the lists directory
106113
stamp_file = '/var/lib/apt/lists/partial'

0 commit comments

Comments
 (0)