The same, but clearer and less code?
This commit is contained in:
parent
95bca18bd3
commit
f5d8419d69
@ -223,8 +223,10 @@ 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 = true;
|
boolean success = false;
|
||||||
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) {
|
||||||
@ -263,12 +265,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 success = false;
|
return 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 success = false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] sig = certs[0].getEncoded();
|
byte[] sig = certs[0].getEncoded();
|
||||||
@ -286,7 +288,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 success = false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -325,21 +327,24 @@ 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 success = false;
|
return 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