Accept declaration of maxage from repos

This commit is contained in:
Ciaran Gultnieks 2013-11-26 19:59:42 +00:00
parent 7dc56e6009
commit d21788569f

View File

@ -61,7 +61,16 @@ public class RepoXMLHandler extends DefaultHandler {
private DB.Apk curapk = null;
private StringBuilder curchars = new StringBuilder();
// After processing the XML, this will be null if the index didn't specify
// a maximum age - otherwise it will be the value specified.
private String maxage;
// After processing the XML, this will be null if the index specified a
// public key - otherwise a public key. This is used for TOFU where an
// index.xml is read on the first connection, and a signed index.jar is
// expected on all subsequent connections.
private String pubkey;
private String name;
private String description;
private String hashType;
@ -255,6 +264,7 @@ public class RepoXMLHandler extends DefaultHandler {
String pk = attributes.getValue("", "pubkey");
if (pk != null)
pubkey = pk;
maxage = attributes.getValue("", "maxage");
String nm = attributes.getValue("", "name");
if (nm != null)
name = nm;
@ -458,6 +468,21 @@ public class RepoXMLHandler extends DefaultHandler {
}
}
if (handler.maxage != null) {
int maxage = Integer.parseInt(handler.maxage);
if (maxage != repo.maxage) {
Log.d("FDroid",
"Repo specified a new maximum age - updated");
repo.maxage = maxage;
try {
DB db = DB.getDB();
db.updateRepoByAddress(repo);
} finally {
DB.releaseDB();
}
}
}
} else if (code == 304) {
// The index is unchanged since we last read it. We just mark
// everything that came from this repo as being updated.