cpp: Update key with --with-secret instead of updating it twice
* lang/cpp/src/key.cpp (Key::update): Call Context::key() only once with KeyListMode::WithSecret. -- With gpg >= 2.1, get the key with --with-secret instead of first trying to get the secret key and, if that fails, getting the public key. GnuPG-bug-id: 4794
This commit is contained in:
parent
13bcc6680a
commit
3dd7377e12
@ -29,6 +29,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "tofuinfo.h"
|
#include "tofuinfo.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
#include "engineinfo.h"
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
@ -363,11 +364,17 @@ void Key::update()
|
|||||||
KeyListMode::SignatureNotations |
|
KeyListMode::SignatureNotations |
|
||||||
KeyListMode::Validate |
|
KeyListMode::Validate |
|
||||||
KeyListMode::WithTofu |
|
KeyListMode::WithTofu |
|
||||||
KeyListMode::WithKeygrip);
|
KeyListMode::WithKeygrip |
|
||||||
|
KeyListMode::WithSecret);
|
||||||
Error err;
|
Error err;
|
||||||
auto newKey = ctx->key(primaryFingerprint(), err, true);
|
Key newKey;
|
||||||
// Not secret so we get the information from the pubring.
|
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.0") {
|
||||||
if (newKey.isNull()) {
|
newKey = ctx->key(primaryFingerprint(), err, true);
|
||||||
|
// Not secret so we get the information from the pubring.
|
||||||
|
if (newKey.isNull()) {
|
||||||
|
newKey = ctx->key(primaryFingerprint(), err, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
newKey = ctx->key(primaryFingerprint(), err, false);
|
newKey = ctx->key(primaryFingerprint(), err, false);
|
||||||
}
|
}
|
||||||
delete ctx;
|
delete ctx;
|
||||||
@ -375,7 +382,6 @@ void Key::update()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
swap(newKey);
|
swap(newKey);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
Loading…
Reference in New Issue
Block a user