chiark / gitweb /
Allow definition of index max age in repo config
authorCiaran Gultnieks <ciaran@ciarang.com>
Tue, 26 Nov 2013 22:07:47 +0000 (22:07 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Tue, 26 Nov 2013 22:07:47 +0000 (22:07 +0000)
config.sample.py
fdroidserver/common.py
fdroidserver/update.py

index 6de1fcca8c23235cb2833b45607a9a346a907d68..712167b3b0dffc9fcbdfc11d9371746c867e3585 100644 (file)
@@ -30,6 +30,13 @@ gradle_plugin = "0.6.+"
 # This corresponds to 72x72 pixels, i.e. mdpi
 icon_max_size = 72
 
+# Set the maximum age (in days) of an index that a client should accept from
+# this repo. Setting it to 0 or not setting it at all disables this
+# functionality. If you do set this to a non-zero value, you need to ensure
+# that your index is updated much more frequently than the specified interval.
+# The same policy is applied to the archive repo, if there is one.
+repo_maxage = 0
+
 repo_url = "https://f-droid.org/repo"
 repo_name = "F-Droid"
 repo_icon = "fdroid-icon.png"
index 6c8b65c66b94539daa09425dce7c1498cb3bfea6..8a2875e025334c730bce87d55f4b7f87ec5c850e 100644 (file)
@@ -61,7 +61,8 @@ def read_config(opts, config_file='config.py'):
         'update_stats': False,
         'archive_older': 0,
         'max_icon_size': 72,
-        'stats_to_carbon': False
+        'stats_to_carbon': False,
+        'repo_maxage': 0
     }
     if options.verbose:
         print "Reading %s..." % config_file
index 86f103b1e7c40cfea4f123a12421a0d6094c8642..84321a243c1f85cbbdd4b9e31e341b0b9f95938c 100644 (file)
@@ -467,11 +467,15 @@ def make_index(apps, apks, repodir, archive, categories):
     repoel = doc.createElement("repo")
     if archive:
         repoel.setAttribute("name", config['archive_name'])
+        if config['repo_maxage'] != 0:
+            repoel.setAttribute("maxage", str(config['repo_maxage']))
         repoel.setAttribute("icon", os.path.basename(config['archive_icon']))
         repoel.setAttribute("url", config['archive_url'])
         addElement('description', config['archive_description'], doc, repoel)
     else:
         repoel.setAttribute("name", config['repo_name'])
+        if config['repo_maxage'] != 0:
+            repoel.setAttribute("maxage", str(config['repo_maxage']))
         repoel.setAttribute("icon", os.path.basename(config['repo_icon']))
         repoel.setAttribute("url", config['repo_url'])
         addElement('description', config['repo_description'], doc, repoel)