A couple of fixes to the repo update process
This commit is contained in:
parent
861d094e9d
commit
2c39dae035
@ -271,7 +271,7 @@ public class AppDetails extends ListActivity {
|
|||||||
download_handler.sendMessage(msg);
|
download_handler.sendMessage(msg);
|
||||||
|
|
||||||
BufferedInputStream getit = new BufferedInputStream(new URL(
|
BufferedInputStream getit = new BufferedInputStream(new URL(
|
||||||
remotefile).openStream());
|
remotefile).openStream(), 8192);
|
||||||
|
|
||||||
FileOutputStream saveit = new FileOutputStream(localfile);
|
FileOutputStream saveit = new FileOutputStream(localfile);
|
||||||
BufferedOutputStream bout = new BufferedOutputStream(saveit, 1024);
|
BufferedOutputStream bout = new BufferedOutputStream(saveit, 1024);
|
||||||
|
@ -133,10 +133,10 @@ public class DB {
|
|||||||
Cursor c = db.rawQuery(
|
Cursor c = db.rawQuery(
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' AND name= '"
|
"SELECT name FROM sqlite_master WHERE type='table' AND name= '"
|
||||||
+ TABLE_REPO + "'", null);
|
+ TABLE_REPO + "'", null);
|
||||||
if (c.getCount() == 0) {
|
boolean newinst = (c.getCount() == 0);
|
||||||
reset();
|
|
||||||
}
|
|
||||||
c.close();
|
c.close();
|
||||||
|
if(newinst)
|
||||||
|
reset();
|
||||||
|
|
||||||
mPm = ctx.getPackageManager();
|
mPm = ctx.getPackageManager();
|
||||||
}
|
}
|
||||||
@ -209,6 +209,7 @@ public class DB {
|
|||||||
app.apks.add(apk);
|
app.apks.add(apk);
|
||||||
c2.moveToNext();
|
c2.moveToNext();
|
||||||
}
|
}
|
||||||
|
c2.close();
|
||||||
|
|
||||||
result.add(app);
|
result.add(app);
|
||||||
c.moveToNext();
|
c.moveToNext();
|
||||||
@ -262,6 +263,10 @@ public class DB {
|
|||||||
|
|
||||||
// Called before a repo update starts.
|
// Called before a repo update starts.
|
||||||
public void beginUpdate() {
|
public void beginUpdate() {
|
||||||
|
// Get a list of all apps. All the apps and apks in this list will
|
||||||
|
// have 'updated' set to false at this point, and we will only set
|
||||||
|
// it to true when we see the app/apk in a repository. Thus, at the
|
||||||
|
// end, any that are still false can be removed.
|
||||||
updateApps = getApps(null, null, true);
|
updateApps = getApps(null, null, true);
|
||||||
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
||||||
+ " apps before starting.");
|
+ " apps before starting.");
|
||||||
@ -275,14 +280,20 @@ public class DB {
|
|||||||
if (!app.updated) {
|
if (!app.updated) {
|
||||||
// The application hasn't been updated, so it's no longer
|
// The application hasn't been updated, so it's no longer
|
||||||
// in the repos.
|
// in the repos.
|
||||||
|
Log.d("FDroid", "AppUpdate: " + app.name
|
||||||
|
+ " is no longer in any repository - removing");
|
||||||
db.delete(TABLE_APP, "id = '" + app.id + "'", null);
|
db.delete(TABLE_APP, "id = '" + app.id + "'", null);
|
||||||
|
db.delete(TABLE_APK, "id = '" + app.id + "'", null);
|
||||||
} else {
|
} else {
|
||||||
for (Apk apk : app.apks) {
|
for (Apk apk : app.apks) {
|
||||||
if (!apk.updated) {
|
if (!apk.updated) {
|
||||||
// The package hasn't been updated, so this is a
|
// The package hasn't been updated, so this is a
|
||||||
// version that's no longer available.
|
// version that's no longer available.
|
||||||
|
Log.d("FDroid", "AppUpdate: Package " + apk.id + "/"
|
||||||
|
+ apk.version
|
||||||
|
+ " is no longer in any repository - removing");
|
||||||
db.delete(TABLE_APK, "id = '" + app.id
|
db.delete(TABLE_APK, "id = '" + app.id
|
||||||
+ " and version ='" + apk.version + "'", null);
|
+ "' and version ='" + apk.version + "'", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,6 +339,7 @@ public class DB {
|
|||||||
app.hasUpdates = true;
|
app.hasUpdates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
@ -338,6 +350,7 @@ public class DB {
|
|||||||
updateAppIfDifferent(null, upapp);
|
updateAppIfDifferent(null, upapp);
|
||||||
for (Apk upapk : upapp.apks) {
|
for (Apk upapk : upapp.apks) {
|
||||||
updateApkIfDifferent(null, upapk);
|
updateApkIfDifferent(null, upapk);
|
||||||
|
upapk.updated = true;
|
||||||
}
|
}
|
||||||
upapp.updated = true;
|
upapp.updated = true;
|
||||||
updateApps.add(upapp);
|
updateApps.add(upapp);
|
||||||
|
@ -434,7 +434,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
try {
|
try {
|
||||||
SAXParser sp = spf.newSAXParser();
|
SAXParser sp = spf.newSAXParser();
|
||||||
XMLReader xr = sp.getXMLReader();
|
XMLReader xr = sp.getXMLReader();
|
||||||
RepoXMLHandler handler = new RepoXMLHandler(this, srv);
|
RepoXMLHandler handler = new RepoXMLHandler(this, srv, db);
|
||||||
xr.setContentHandler(handler);
|
xr.setContentHandler(handler);
|
||||||
|
|
||||||
InputStreamReader isr = new FileReader(new File(XML_PATH));
|
InputStreamReader isr = new FileReader(new File(XML_PATH));
|
||||||
|
@ -39,24 +39,16 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
Context mctx;
|
Context mctx;
|
||||||
String mserver;
|
String mserver;
|
||||||
|
|
||||||
private DB db = null;
|
private DB db;
|
||||||
|
|
||||||
private DB.App curapp = null;
|
private DB.App curapp = null;
|
||||||
private DB.Apk curapk = null;
|
private DB.Apk curapk = null;
|
||||||
private String curel = null;
|
private String curel = null;
|
||||||
|
|
||||||
public RepoXMLHandler(Context ctx, String srv) {
|
public RepoXMLHandler(Context ctx, String srv,DB db) {
|
||||||
mctx = ctx;
|
mctx = ctx;
|
||||||
mserver = srv;
|
mserver = srv;
|
||||||
db = new DB(mctx);
|
this.db = db;
|
||||||
db.beginUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endDocument() throws SAXException {
|
|
||||||
super.endDocument();
|
|
||||||
db.endUpdate();
|
|
||||||
db.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user