Ensure that description is not null when parsing index.

At time of writing (and for some time before), fdroidserver has forced
a description of "No description available" for apps which don't have
descriptions at all:

 * https://gitlab.com/fdroid/fdroidserver/blob/0.6.0/fdroidserver/metadata.py#L876

However, if the description is not set for whatever reason, it should not
crash the client.
This commit is contained in:
Peter Serwylo 2016-08-16 00:20:19 +10:00
parent 20a5f42359
commit b855c745e0

View File

@ -265,6 +265,11 @@ public class RepoXMLHandler extends DefaultHandler {
} else if ("application".equals(localName) && curapp == null) { } else if ("application".equals(localName) && curapp == null) {
curapp = new App(); curapp = new App();
curapp.packageName = attributes.getValue("", "id"); curapp.packageName = attributes.getValue("", "id");
// To appease the NON NULL constraint in the DB. Usually there is a description, and it
// is quite difficult to get an app to _not_ have a description when using fdroidserver.
// However, it shouldn't crash the client when this happens.
curapp.description = "";
} else if ("package".equals(localName) && curapp != null && curapk == null) { } else if ("package".equals(localName) && curapp != null && curapk == null) {
curapk = new Apk(); curapk = new Apk();
curapk.packageName = curapp.packageName; curapk.packageName = curapp.packageName;