Accept declaration of maxage from repos
This commit is contained in:
parent
7dc56e6009
commit
d21788569f
@ -61,7 +61,16 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
private DB.Apk curapk = null;
|
private DB.Apk curapk = null;
|
||||||
private StringBuilder curchars = new StringBuilder();
|
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 pubkey;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String hashType;
|
private String hashType;
|
||||||
@ -255,6 +264,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
String pk = attributes.getValue("", "pubkey");
|
String pk = attributes.getValue("", "pubkey");
|
||||||
if (pk != null)
|
if (pk != null)
|
||||||
pubkey = pk;
|
pubkey = pk;
|
||||||
|
maxage = attributes.getValue("", "maxage");
|
||||||
String nm = attributes.getValue("", "name");
|
String nm = attributes.getValue("", "name");
|
||||||
if (nm != null)
|
if (nm != null)
|
||||||
name = nm;
|
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) {
|
} else if (code == 304) {
|
||||||
// The index is unchanged since we last read it. We just mark
|
// The index is unchanged since we last read it. We just mark
|
||||||
// everything that came from this repo as being updated.
|
// everything that came from this repo as being updated.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user