Permalink
Browse files

scripts/reproducible-check: Expire cache file after 1 day.

  • Loading branch information...
lamby committed Sep 15, 2017
1 parent 01cd13b commit 6efc2514ac58f65f1f3dd08f71f8fae63b26230e
Showing with 9 additions and 3 deletions.
  1. +9 −3 scripts/reproducible-check
View
@@ -20,6 +20,7 @@ import bz2
import apt
import sys
import json
import time
import logging
import requests
import argparse
@@ -44,6 +45,7 @@ class ReproducibleCheck(object):
CACHE = os.path.join(xdg_cache_home, NAME, 'reproducible.json.bz2')
VERSION = 1
STATUS_URL = 'https://tests.reproducible-builds.org/debian/reproducible.json.bz2'
CACHE_AGE_SECONDS = 86400
@classmethod
def parse(cls):
@@ -105,9 +107,13 @@ class ReproducibleCheck(object):
def update_cache(self):
self.log.debug("Checking cache file %s ...", self.CACHE)
if os.path.exists(self.CACHE):
self.log.debug("Cache is up to date")
return
try:
if os.path.getmtime(self.CACHE) >= \
time.time() - self.CACHE_AGE_SECONDS:
self.log.debug("Cache is up to date")
return
except OSError:
pass
self.log.info("Updating cache...")

0 comments on commit 6efc251

Please sign in to comment.