mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 09:12:16 -05:00
Merge pull request #1317 from adithyaphilip/master
Merge key from Keyserver with that from Keybase instead of replacing
This commit is contained in:
commit
af5fc66229
@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
@ -244,25 +243,25 @@ public class ImportExportOperation extends BaseOperation {
|
||||
try {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_KEYBASE, 2, entry.mKeybaseName);
|
||||
byte[] data = keybaseServer.get(entry.mKeybaseName).getBytes();
|
||||
key = UncachedKeyRing.decodeFromData(data);
|
||||
UncachedKeyRing keybaseKey = UncachedKeyRing.decodeFromData(data);
|
||||
|
||||
// If there already is a key (of keybase origin), merge the two
|
||||
if (key != null) {
|
||||
// If there already is a key, merge the two
|
||||
if (key != null && keybaseKey != null) {
|
||||
log.add(LogType.MSG_IMPORT_MERGE, 3);
|
||||
UncachedKeyRing merged = UncachedKeyRing.decodeFromData(data);
|
||||
merged = key.merge(merged, log, 4);
|
||||
keybaseKey = key.merge(keybaseKey, log, 4);
|
||||
// If the merge didn't fail, use the new merged key
|
||||
if (merged != null) {
|
||||
key = merged;
|
||||
}
|
||||
if (keybaseKey != null) {
|
||||
key = keybaseKey;
|
||||
} else {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3);
|
||||
key = UncachedKeyRing.decodeFromData(data);
|
||||
log.add(LogType.MSG_IMPORT_MERGE_ERROR, 4);
|
||||
}
|
||||
} else if (keybaseKey != null) {
|
||||
key = keybaseKey;
|
||||
}
|
||||
} catch (Keyserver.QueryFailedException e) {
|
||||
// download failed, too bad. just proceed
|
||||
Log.e(Constants.TAG, "query failed", e);
|
||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3);
|
||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -696,6 +696,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_IMPORT_FETCH_KEYBASE (LogLevel.INFO, R.string.msg_import_fetch_keybase),
|
||||
MSG_IMPORT_KEYSERVER (LogLevel.DEBUG, R.string.msg_import_keyserver),
|
||||
MSG_IMPORT_MERGE (LogLevel.DEBUG, R.string.msg_import_merge),
|
||||
MSG_IMPORT_MERGE_ERROR (LogLevel.ERROR, R.string.msg_import_merge_error),
|
||||
MSG_IMPORT_FINGERPRINT_ERROR (LogLevel.ERROR, R.string.msg_import_fingerprint_error),
|
||||
MSG_IMPORT_FINGERPRINT_OK (LogLevel.DEBUG, R.string.msg_import_fingerprint_ok),
|
||||
MSG_IMPORT_ERROR (LogLevel.ERROR, R.string.msg_import_error),
|
||||
|
@ -1154,6 +1154,7 @@
|
||||
<string name="msg_import_fingerprint_error">"Fingerprint of fetched key didn't match expected!"</string>
|
||||
<string name="msg_import_fingerprint_ok">"Fingerprint check OK"</string>
|
||||
<string name="msg_import_merge">"Merging retrieved data"</string>
|
||||
<string name="msg_import_merge_error">"Error merging retrieved data!"</string>
|
||||
<string name="msg_import_error">"Import operation failed!"</string>
|
||||
<string name="msg_import_error_io">"Import operation failed due to i/o error!"</string>
|
||||
<string name="msg_import_partial">"Import operation successful, with errors!"</string>
|
||||
|
Loading…
Reference in New Issue
Block a user