prevent recursive consolidate

This commit is contained in:
Vincent Breitmoser 2015-01-31 18:26:20 +01:00
parent 43930ed8f2
commit 5466d1e980
5 changed files with 11 additions and 5 deletions

View File

@ -520,6 +520,7 @@ public abstract class OperationResult implements Parcelable {
MSG_CON_ERROR_PUBLIC (LogLevel.ERROR, R.string.msg_con_error_public),
MSG_CON_ERROR_SECRET (LogLevel.ERROR, R.string.msg_con_error_secret),
MSG_CON_RECOVER (LogLevel.DEBUG, R.string.msg_con_recover),
MSG_CON_RECURSIVE (LogLevel.OK, R.string.msg_con_recursive),
MSG_CON_REIMPORT_PUBLIC (LogLevel.DEBUG, R.plurals.msg_con_reimport_public),
MSG_CON_REIMPORT_PUBLIC_SKIP (LogLevel.DEBUG, R.string.msg_con_reimport_public_skip),
MSG_CON_REIMPORT_SECRET (LogLevel.DEBUG, R.plurals.msg_con_reimport_secret),

View File

@ -1053,6 +1053,11 @@ public class ProviderHelper {
log.add(LogType.MSG_CON, indent);
indent += 1;
if (mConsolidateCritical) {
log.add(LogType.MSG_CON_RECURSIVE, indent);
return new ConsolidateResult(ConsolidateResult.RESULT_OK, log);
}
progress.setProgress(R.string.progress_con_saving, 0, 100);
// The consolidate operation can never be cancelled!
@ -1219,13 +1224,11 @@ public class ProviderHelper {
log.add(LogType.MSG_CON_DB_CLEAR, indent);
mContentResolver.delete(KeyRings.buildUnifiedKeyRingsUri(), null, null);
ParcelableFileCache<ParcelableKeyRing> cacheSecret =
new ParcelableFileCache<>(mContext, "consolidate_secret.pcl");
ParcelableFileCache<ParcelableKeyRing> cachePublic =
new ParcelableFileCache<>(mContext, "consolidate_public.pcl");
ParcelableFileCache<ParcelableKeyRing> cacheSecret, cachePublic;
// Set flag that we have a cached consolidation here
try {
cacheSecret = new ParcelableFileCache<>(mContext, "consolidate_secret.pcl");
IteratorWithSize<ParcelableKeyRing> itSecrets = cacheSecret.readCache(false);
int numSecrets = itSecrets.getSize();
@ -1253,6 +1256,7 @@ public class ProviderHelper {
try {
cachePublic = new ParcelableFileCache<>(mContext, "consolidate_public.pcl");
IteratorWithSize<ParcelableKeyRing> itPublics = cachePublic.readCache();
int numPublics = itPublics.getSize();

View File

@ -131,6 +131,7 @@ public class KeychainIntentServiceHandler extends Handler {
case MESSAGE_PREVENT_CANCEL:
mProgressDialogFragment.setPreventCancel(true);
break;
default:
Log.e(Constants.TAG, "unknown handler message!");

View File

@ -104,7 +104,6 @@ public class ParcelableFileCache<E extends Parcelable> {
throw new IOException(e);
}
// yes this is sloppy data flow. WE WOULDN'T NEED THIS WITH TUPLE RETURN TYPES
final int numEntries = ois.readInt();
return new IteratorWithSize<E>() {

View File

@ -886,6 +886,7 @@
<string name="msg_con_error_public">"Error reimporting public keys!"</string>
<string name="msg_con_error_secret">"Error reimporting secret keys!"</string>
<string name="msg_con_recover">"Resuming consolidation process"</string>
<string name="msg_con_recursive">"Skipping recursive consolidation"</string>
<string name="msg_con_recover_unknown">"Resuming consolidation process from unknown state"</string>
<plurals name="msg_con_reimport_public">
<item quantity="one">"Reimporting one public key"</item>