Add 'repo.version' integer
This commit is contained in:
parent
eeeace080f
commit
e9abbfa743
@ -430,6 +430,7 @@ public class DB {
|
|||||||
public String address;
|
public String address;
|
||||||
public String name;
|
public String name;
|
||||||
public String description;
|
public String description;
|
||||||
|
public int version; // index version, i.e. what fdroidserver built it - 0 if not specified
|
||||||
public boolean inuse;
|
public boolean inuse;
|
||||||
public int priority;
|
public int priority;
|
||||||
public String pubkey; // null for an unsigned repo
|
public String pubkey; // null for an unsigned repo
|
||||||
@ -438,7 +439,7 @@ public class DB {
|
|||||||
public String lastetag; // last etag we updated from, null forces update
|
public String lastetag; // last etag we updated from, null forces update
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int DBVersion = 33;
|
private final int DBVersion = 34;
|
||||||
|
|
||||||
private static void createAppApk(SQLiteDatabase db) {
|
private static void createAppApk(SQLiteDatabase db) {
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP);
|
||||||
@ -504,6 +505,7 @@ public class DB {
|
|||||||
mContext.getString(R.string.default_repo_name));
|
mContext.getString(R.string.default_repo_name));
|
||||||
values.put("description",
|
values.put("description",
|
||||||
mContext.getString(R.string.default_repo_description));
|
mContext.getString(R.string.default_repo_description));
|
||||||
|
values.put("version", 0);
|
||||||
String pubkey = mContext.getString(R.string.default_repo_pubkey);
|
String pubkey = mContext.getString(R.string.default_repo_pubkey);
|
||||||
String fingerprint = DB.calcFingerprint(pubkey);
|
String fingerprint = DB.calcFingerprint(pubkey);
|
||||||
values.put("pubkey", pubkey);
|
values.put("pubkey", pubkey);
|
||||||
@ -521,9 +523,11 @@ public class DB {
|
|||||||
mContext.getString(R.string.default_repo_name2));
|
mContext.getString(R.string.default_repo_name2));
|
||||||
values.put("description",
|
values.put("description",
|
||||||
mContext.getString(R.string.default_repo_description2));
|
mContext.getString(R.string.default_repo_description2));
|
||||||
|
values.put("version", 0);
|
||||||
// default #2 is /archive which has the same key as /repo
|
// default #2 is /archive which has the same key as /repo
|
||||||
values.put("pubkey", pubkey);
|
values.put("pubkey", pubkey);
|
||||||
values.put("fingerprint", fingerprint);
|
values.put("fingerprint", fingerprint);
|
||||||
|
values.put("maxage", 0);
|
||||||
values.put("inuse", 0);
|
values.put("inuse", 0);
|
||||||
values.put("priority", 20);
|
values.put("priority", 20);
|
||||||
values.put("lastetag", (String) null);
|
values.put("lastetag", (String) null);
|
||||||
@ -611,6 +615,10 @@ public class DB {
|
|||||||
if (oldVersion < 30) {
|
if (oldVersion < 30) {
|
||||||
db.execSQL("alter table " + TABLE_REPO + " add column maxage integer not null default 0");
|
db.execSQL("alter table " + TABLE_REPO + " add column maxage integer not null default 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < 34) {
|
||||||
|
db.execSQL("alter table " + TABLE_REPO + " add column version integer not null default 0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1283,8 +1291,8 @@ public class DB {
|
|||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.query(TABLE_REPO, new String[] { "address", "name",
|
c = db.query(TABLE_REPO, new String[] { "address", "name",
|
||||||
"description", "inuse", "priority", "pubkey", "fingerprint",
|
"description", "version", "inuse", "priority", "pubkey",
|
||||||
"maxage", "lastetag" },
|
"fingerprint", "maxage", "lastetag" },
|
||||||
"id = ?", new String[] { Integer.toString(id) }, null, null, null);
|
"id = ?", new String[] { Integer.toString(id) }, null, null, null);
|
||||||
if (!c.moveToFirst())
|
if (!c.moveToFirst())
|
||||||
return null;
|
return null;
|
||||||
@ -1293,12 +1301,13 @@ public class DB {
|
|||||||
repo.address = c.getString(0);
|
repo.address = c.getString(0);
|
||||||
repo.name = c.getString(1);
|
repo.name = c.getString(1);
|
||||||
repo.description = c.getString(2);
|
repo.description = c.getString(2);
|
||||||
repo.inuse = (c.getInt(3) == 1);
|
repo.version = c.getInt(3);
|
||||||
repo.priority = c.getInt(4);
|
repo.inuse = (c.getInt(4) == 1);
|
||||||
repo.pubkey = c.getString(5);
|
repo.priority = c.getInt(5);
|
||||||
repo.fingerprint = c.getString(6);
|
repo.pubkey = c.getString(6);
|
||||||
repo.maxage = c.getInt(7);
|
repo.fingerprint = c.getString(7);
|
||||||
repo.lastetag = c.getString(8);
|
repo.maxage = c.getInt(8);
|
||||||
|
repo.lastetag = c.getString(9);
|
||||||
return repo;
|
return repo;
|
||||||
} finally {
|
} finally {
|
||||||
if (c != null)
|
if (c != null)
|
||||||
@ -1312,8 +1321,8 @@ public class DB {
|
|||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.query(TABLE_REPO, new String[] { "id", "address", "name",
|
c = db.query(TABLE_REPO, new String[] { "id", "address", "name",
|
||||||
"description", "inuse", "priority", "pubkey", "fingerprint",
|
"description", "version", "inuse", "priority", "pubkey",
|
||||||
"maxage", "lastetag" },
|
"fingerprint", "maxage", "lastetag" },
|
||||||
null, null, null, null, "priority");
|
null, null, null, null, "priority");
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
@ -1322,12 +1331,13 @@ public class DB {
|
|||||||
repo.address = c.getString(1);
|
repo.address = c.getString(1);
|
||||||
repo.name = c.getString(2);
|
repo.name = c.getString(2);
|
||||||
repo.description = c.getString(3);
|
repo.description = c.getString(3);
|
||||||
repo.inuse = (c.getInt(4) == 1);
|
repo.version = c.getInt(4);
|
||||||
repo.priority = c.getInt(5);
|
repo.inuse = (c.getInt(5) == 1);
|
||||||
repo.pubkey = c.getString(6);
|
repo.priority = c.getInt(6);
|
||||||
repo.fingerprint = c.getString(7);
|
repo.pubkey = c.getString(7);
|
||||||
repo.maxage = c.getInt(8);
|
repo.fingerprint = c.getString(8);
|
||||||
repo.lastetag = c.getString(9);
|
repo.maxage = c.getInt(9);
|
||||||
|
repo.lastetag = c.getString(10);
|
||||||
repos.add(repo);
|
repos.add(repo);
|
||||||
c.moveToNext();
|
c.moveToNext();
|
||||||
}
|
}
|
||||||
@ -1357,6 +1367,7 @@ public class DB {
|
|||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("name", repo.name);
|
values.put("name", repo.name);
|
||||||
values.put("description", repo.description);
|
values.put("description", repo.description);
|
||||||
|
values.put("version", repo.version);
|
||||||
values.put("inuse", repo.inuse);
|
values.put("inuse", repo.inuse);
|
||||||
values.put("priority", repo.priority);
|
values.put("priority", repo.priority);
|
||||||
values.put("pubkey", repo.pubkey);
|
values.put("pubkey", repo.pubkey);
|
||||||
@ -1380,12 +1391,14 @@ public class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addRepo(String address, String name, String description,
|
public void addRepo(String address, String name, String description,
|
||||||
int priority, String pubkey, String fingerprint, int maxage, boolean inuse)
|
int version, int priority, String pubkey, String fingerprint,
|
||||||
|
int maxage, boolean inuse)
|
||||||
throws SecurityException {
|
throws SecurityException {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("address", address);
|
values.put("address", address);
|
||||||
values.put("name", name);
|
values.put("name", name);
|
||||||
values.put("description", description);
|
values.put("description", description);
|
||||||
|
values.put("version", version);
|
||||||
values.put("inuse", inuse ? 1 : 0);
|
values.put("inuse", inuse ? 1 : 0);
|
||||||
values.put("priority", priority);
|
values.put("priority", priority);
|
||||||
values.put("pubkey", pubkey);
|
values.put("pubkey", pubkey);
|
||||||
|
@ -218,7 +218,7 @@ public class ManageRepo extends ListActivity {
|
|||||||
protected void addRepo(String repoUri, String fingerprint) {
|
protected void addRepo(String repoUri, String fingerprint) {
|
||||||
try {
|
try {
|
||||||
DB db = DB.getDB();
|
DB db = DB.getDB();
|
||||||
db.addRepo(repoUri, null, null, 10, null, fingerprint, 0, true);
|
db.addRepo(repoUri, null, null, 0, 10, null, fingerprint, 0, true);
|
||||||
} finally {
|
} finally {
|
||||||
DB.releaseDB();
|
DB.releaseDB();
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,9 @@ 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
|
// After processing the XML, these will be null if the index didn't specify
|
||||||
// a maximum age - otherwise it will be the value specified.
|
// them - otherwise it will be the value specified.
|
||||||
|
private String version;
|
||||||
private String maxage;
|
private String maxage;
|
||||||
|
|
||||||
// After processing the XML, this will be null if the index specified a
|
// After processing the XML, this will be null if the index specified a
|
||||||
@ -262,10 +263,12 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
public void startElement(String uri, String localName, String qName,
|
public void startElement(String uri, String localName, String qName,
|
||||||
Attributes attributes) throws SAXException {
|
Attributes attributes) throws SAXException {
|
||||||
super.startElement(uri, localName, qName, attributes);
|
super.startElement(uri, localName, qName, attributes);
|
||||||
|
|
||||||
if (localName.equals("repo")) {
|
if (localName.equals("repo")) {
|
||||||
String pk = attributes.getValue("", "pubkey");
|
String pk = attributes.getValue("", "pubkey");
|
||||||
if (pk != null)
|
if (pk != null)
|
||||||
pubkey = pk;
|
pubkey = pk;
|
||||||
|
version = attributes.getValue("", "version");
|
||||||
maxage = attributes.getValue("", "maxage");
|
maxage = attributes.getValue("", "maxage");
|
||||||
String nm = attributes.getValue("", "name");
|
String nm = attributes.getValue("", "name");
|
||||||
if (nm != null)
|
if (nm != null)
|
||||||
@ -273,6 +276,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
String dc = attributes.getValue("", "description");
|
String dc = attributes.getValue("", "description");
|
||||||
if (dc != null)
|
if (dc != null)
|
||||||
description = dc;
|
description = dc;
|
||||||
|
|
||||||
} else if (localName.equals("application") && curapp == null) {
|
} else if (localName.equals("application") && curapp == null) {
|
||||||
curapp = new DB.App();
|
curapp = new DB.App();
|
||||||
curapp.detail_Populated = true;
|
curapp.detail_Populated = true;
|
||||||
@ -283,11 +287,13 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
new ProgressListener.Event(
|
new ProgressListener.Event(
|
||||||
RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML, progressCounter,
|
RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML, progressCounter,
|
||||||
totalAppCount, progressData));
|
totalAppCount, progressData));
|
||||||
|
|
||||||
} else if (localName.equals("package") && curapp != null && curapk == null) {
|
} else if (localName.equals("package") && curapp != null && curapk == null) {
|
||||||
curapk = new DB.Apk();
|
curapk = new DB.Apk();
|
||||||
curapk.id = curapp.id;
|
curapk.id = curapp.id;
|
||||||
curapk.repo = repo.id;
|
curapk.repo = repo.id;
|
||||||
hashType = null;
|
hashType = null;
|
||||||
|
|
||||||
} else if (localName.equals("hash") && curapk != null) {
|
} else if (localName.equals("hash") && curapk != null) {
|
||||||
hashType = attributes.getValue("", "type");
|
hashType = attributes.getValue("", "type");
|
||||||
}
|
}
|
||||||
@ -469,6 +475,17 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
DB.releaseDB();
|
DB.releaseDB();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean updateRepo = false;
|
||||||
|
|
||||||
|
if (handler.version != null) {
|
||||||
|
int version = Integer.parseInt(handler.version);
|
||||||
|
if (version != repo.version) {
|
||||||
|
Log.d("FDroid", "Repo specified a new version: from "
|
||||||
|
+ repo.version + " to " + version);
|
||||||
|
repo.version = version;
|
||||||
|
updateRepo = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (handler.maxage != null) {
|
if (handler.maxage != null) {
|
||||||
int maxage = Integer.parseInt(handler.maxage);
|
int maxage = Integer.parseInt(handler.maxage);
|
||||||
@ -476,6 +493,11 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
Log.d("FDroid",
|
Log.d("FDroid",
|
||||||
"Repo specified a new maximum age - updated");
|
"Repo specified a new maximum age - updated");
|
||||||
repo.maxage = maxage;
|
repo.maxage = maxage;
|
||||||
|
updateRepo = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateRepo) {
|
||||||
try {
|
try {
|
||||||
DB db = DB.getDB();
|
DB db = DB.getDB();
|
||||||
db.updateRepoByAddress(repo);
|
db.updateRepoByAddress(repo);
|
||||||
@ -483,7 +505,6 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
DB.releaseDB();
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user