Commit 836adc09 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Update the key cache after the import

Suspend the automatic refresh of the key cache during the import and
explicitly trigger an update of the key cache after the import. This
way we can be sure that the key cache is up-to-date when we perform
the post-processing of the certificate import.

GnuPG-bug-id: 5638
parent ea80bb76
......@@ -573,6 +573,16 @@ void ImportCertificatesCommand::Private::tryToFinish()
return;
}
auto keyCache = KeyCache::mutableInstance();
connect(keyCache.get(), &KeyCache::keyListingDone,
q, [this]() { keyCacheUpdated(); });
keyCache->startKeyListing();
}
void ImportCertificatesCommand::Private::keyCacheUpdated()
{
keyCacheAutoRefreshSuspension.reset();
if (std::any_of(std::cbegin(results), std::cend(results), &importFailed)) {
setImportResultProxyModel(results);
if (std::all_of(std::cbegin(results), std::cend(results),
......@@ -622,6 +632,8 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
return;
}
keyCacheAutoRefreshSuspension = KeyCache::mutableInstance()->suspendAutoRefresh();
connect(job.get(), SIGNAL(result(GpgME::ImportResult)),
q, SLOT(importResult(GpgME::ImportResult)));
connect(job.get(), &Job::progress,
......@@ -662,6 +674,8 @@ void ImportCertificatesCommand::Private::startImport(GpgME::Protocol protocol, c
return;
}
keyCacheAutoRefreshSuspension = KeyCache::mutableInstance()->suspendAutoRefresh();
connect(job.get(), SIGNAL(result(GpgME::ImportResult)),
q, SLOT(importResult(GpgME::ImportResult)));
connect(job.get(), &Job::progress,
......
......@@ -30,6 +30,11 @@ namespace QGpgME
class AbstractImportJob;
}
namespace Kleo
{
class KeyCacheAutoRefreshSuspension;
}
class QByteArray;
struct ImportJobData
......@@ -53,6 +58,7 @@ class Kleo::ImportCertificatesCommand::Private : public Command::Private
{
return static_cast<ImportCertificatesCommand *>(q);
}
public:
explicit Private(ImportCertificatesCommand *qq, KeyListController *c);
~Private() override;
......@@ -80,12 +86,14 @@ public:
private:
void processResults();
void tryToFinish();
void keyCacheUpdated();
private:
bool waitForMoreJobs = false;
std::vector<GpgME::Protocol> nonWorkingProtocols;
std::vector<ImportJobData> jobs;
std::vector<ImportResultData> results;
std::shared_ptr<KeyCacheAutoRefreshSuspension> keyCacheAutoRefreshSuspension;
};
inline Kleo::ImportCertificatesCommand::Private *Kleo::ImportCertificatesCommand::d_func()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment