Revert "The same, but clearer and less code?"
This reverts commit f5d8419d69b279112d5b7fa42a30c606a54e764c. Tunedal came up with a better idea.
This commit is contained in:
parent
f5d8419d69
commit
a364364d99
@ -223,10 +223,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
|
|
||||||
public static boolean doUpdates(Context ctx, DB db) {
|
public static boolean doUpdates(Context ctx, DB db) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
boolean success = false;
|
boolean success = true;
|
||||||
db.beginUpdate();
|
db.beginUpdate();
|
||||||
try
|
|
||||||
{
|
|
||||||
Vector<DB.Repo> repos = db.getRepos();
|
Vector<DB.Repo> repos = db.getRepos();
|
||||||
for (DB.Repo repo : repos) {
|
for (DB.Repo repo : repos) {
|
||||||
if (repo.inuse) {
|
if (repo.inuse) {
|
||||||
@ -265,12 +263,12 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
jar.close();
|
jar.close();
|
||||||
if (certs == null) {
|
if (certs == null) {
|
||||||
Log.d("FDroid", "No signature found in index");
|
Log.d("FDroid", "No signature found in index");
|
||||||
return false;
|
return success = false;
|
||||||
}
|
}
|
||||||
if (certs.length != 1) {
|
if (certs.length != 1) {
|
||||||
Log.d("FDroid", "Expected one signature - found "
|
Log.d("FDroid", "Expected one signature - found "
|
||||||
+ certs.length);
|
+ certs.length);
|
||||||
return false;
|
return success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] sig = certs[0].getEncoded();
|
byte[] sig = certs[0].getEncoded();
|
||||||
@ -288,7 +286,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
|
|
||||||
if (!ssig.equals(repo.pubkey)) {
|
if (!ssig.equals(repo.pubkey)) {
|
||||||
Log.d("FDroid", "Index signature mismatch");
|
Log.d("FDroid", "Index signature mismatch");
|
||||||
return false;
|
return success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -327,24 +325,21 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("FDroid", "Exception updating from " + repo.address
|
Log.e("FDroid", "Exception updating from " + repo.address
|
||||||
+ ":\n" + Log.getStackTraceString(e));
|
+ ":\n" + Log.getStackTraceString(e));
|
||||||
return false;
|
return success = false;
|
||||||
} finally {
|
} finally {
|
||||||
ctx.deleteFile("tempindex.xml");
|
ctx.deleteFile("tempindex.xml");
|
||||||
ctx.deleteFile("tempindex.jar");
|
ctx.deleteFile("tempindex.jar");
|
||||||
|
if (!success)
|
||||||
|
db.cancelUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
success=true;
|
|
||||||
db.endUpdate();
|
db.endUpdate();
|
||||||
Log.d("FDroid", "Update completed in "
|
Log.d("FDroid", "Update completed in "
|
||||||
+ ((System.currentTimeMillis() - startTime) / 1000)
|
+ ((System.currentTimeMillis() - startTime) / 1000)
|
||||||
+ " seconds.");
|
+ " seconds.");
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
|
||||||
if(!success)
|
|
||||||
db.cancelUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user