jhbuild r2729 - in trunk: . jhbuild/utils
- From: fpeters svn gnome org
- To: svn-commits-list gnome org
- Subject: jhbuild r2729 - in trunk: . jhbuild/utils
- Date: Sun, 15 Feb 2009 21:23:57 +0000 (UTC)
Author: fpeters
Date: Sun Feb 15 21:23:57 2009
New Revision: 2729
URL: http://svn.gnome.org/viewvc/jhbuild?rev=2729&view=rev
Log:
* jhbuild/utils/httpcache.py: possibility to pass a age argument when
using httpcache, to have a different expiration age, also passing 0
will make it not using the cache.
Modified:
trunk/ChangeLog
trunk/jhbuild/utils/httpcache.py
Modified: trunk/jhbuild/utils/httpcache.py
==============================================================================
--- trunk/jhbuild/utils/httpcache.py (original)
+++ trunk/jhbuild/utils/httpcache.py Sun Feb 15 21:23:57 2009
@@ -159,7 +159,7 @@
base = base + '-'
return base
- def load(self, uri, nonetwork=False):
+ def load(self, uri, nonetwork=False, age=None):
'''Downloads the file associated with the URI, and returns a local
file name for contents.'''
# pass file URIs straight through -- no need to cache them
@@ -172,7 +172,7 @@
# is the file cached and not expired?
self.read_cache()
entry = self.entries.get(uri)
- if entry:
+ if entry and age != 0:
if (nonetwork or now <= entry.expires):
return os.path.join(self.cachedir, entry.local)
@@ -217,7 +217,9 @@
# set expiry date
entry.expires = _parse_date(expires)
if entry.expires <= now: # ignore expiry times that have already passed
- entry.expires = now + self.default_age
+ if age is None:
+ age = self.default_age
+ entry.expires = now + age
# save cache
self.entries[uri] = entry
@@ -225,9 +227,9 @@
return filename
_cache = None
-def load(uri, nonetwork=False):
+def load(uri, nonetwork=False, age=None):
'''Downloads the file associated with the URI, and returns a local
file name for contents.'''
global _cache
if not _cache: _cache = Cache()
- return _cache.load(uri, nonetwork=nonetwork)
+ return _cache.load(uri, nonetwork=nonetwork, age=age)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]