diff --git a/src/RemoteDatabase.cpp b/src/RemoteDatabase.cpp index ec733d73..3f2471fb 100644 --- a/src/RemoteDatabase.cpp +++ b/src/RemoteDatabase.cpp @@ -369,14 +369,8 @@ void RemoteDatabase::fetch(const QString& url, RequestType type, const QString& return; } - // When the client certificate is different from the one before, clear the access and authentication cache. - // Otherwise Qt might use the old certificate again. - static QString lastClientCert; - if(lastClientCert != clientCert) - { - lastClientCert = clientCert; - m_manager->clearAccessCache(); - } + // Clear access cache if necessary + clearAccessCache(clientCert); // Fetch database and save pending reply. Note that we're only supporting one active download here at the moment. m_currentReply = m_manager->get(request); @@ -427,6 +421,9 @@ void RemoteDatabase::push(const QString& filename, const QString& url, const QSt return; } + // Clear access cache if necessary + clearAccessCache(clientCert); + // Get file data // TODO: Don't read the entire file here but directly pass the file handle to the put() call below in order // to read larger files chunk by chunk. @@ -609,3 +606,15 @@ QString RemoteDatabase::localExists(const QUrl& url, QString identity) return QString(); } } + +void RemoteDatabase::clearAccessCache(const QString& clientCert) +{ + // When the client certificate is different from the one before, clear the access and authentication cache. + // Otherwise Qt might use the old certificate again. + static QString lastClientCert; + if(lastClientCert != clientCert) + { + lastClientCert = clientCert; + m_manager->clearAccessCache(); + } +} diff --git a/src/RemoteDatabase.h b/src/RemoteDatabase.h index d6fe3ed5..97440889 100644 --- a/src/RemoteDatabase.h +++ b/src/RemoteDatabase.h @@ -64,6 +64,10 @@ private: void localAdd(QString filename, QString identity, const QUrl& url); QString localExists(const QUrl& url, QString identity); + // Before using a new client certificate we need to clear the access and authentication cache of the network manager + // object. Otherwise Qt might reuse the old certificate if the requested URL has been used before. + void clearAccessCache(const QString& clientCert); + QNetworkAccessManager* m_manager; QProgressDialog* m_progress; QNetworkReply* m_currentReply;