From da5859eb4615876db9b9109d863a316a8a6bb9e4 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 7 Jun 2022 14:15:17 +0300 Subject: [PATCH] Set TSL modified time to past (#1073) IB-7029 Signed-off-by: Raul Metsma --- client/Application.cpp | 29 ++++++++++++++++------------- client/Application.h | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/client/Application.cpp b/client/Application.cpp index 943aeb90b..56315f43e 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -385,15 +385,18 @@ Application::Application( int &argc, char **argv ) d->signer = new QSigner(api, this); QString cache = confValue(TSLCache).toString(); QDir().mkpath( cache ); + QDateTime tslTime = QDateTime::currentDateTimeUtc().addDays(-7); for(const QString &file: QDir(QStringLiteral(":/TSL/")).entryList()) { - const QString target = cache + "/" + file; - if(!QFile::exists(target) || - readTSLVersion(":/TSL/" + file) > readTSLVersion(target)) + QFile tl(cache + "/" + file); + if(!tl.exists() || + readTSLVersion(":/TSL/" + file) > readTSLVersion(tl.fileName())) { - QFile::remove(target); - QFile::copy(":/TSL/" + file, target); - QFile::setPermissions(target, QFile::Permissions(0x6444)); + tl.remove(); + QFile::copy(":/TSL/" + file, tl.fileName()); + tl.setPermissions(QFile::Permissions(0x6444)); + if(tl.open(QFile::Append)) + tl.setFileTime(tslTime, QFileDevice::FileModificationTime); } } @@ -612,9 +615,9 @@ QVariant Application::confValue( ConfParameter parameter, const QVariant &value return r.isEmpty() ? value.toString() : QString::fromUtf8( r ); } -bool Application::event( QEvent *e ) +bool Application::event(QEvent *event) { - switch( int(e->type()) ) + switch(int(event->type())) { case REOpenEvent::Type: if( !activeWindow() ) @@ -622,7 +625,7 @@ bool Application::event( QEvent *e ) return true; case QEvent::FileOpen: { - QString fileName = static_cast(e)->file().normalized(QString::NormalizationForm_C); + QString fileName = static_cast(event)->file().normalized(QString::NormalizationForm_C); QTimer::singleShot(0, [this, fileName] { parseArgs({ fileName }); }); @@ -632,9 +635,9 @@ bool Application::event( QEvent *e ) // Load here because cocoa NSApplication overides events case QEvent::ApplicationActivate: initMacEvents(); - return Common::event( e ); + return Common::event(event); #endif - default: return Common::event( e ); + default: return Common::event(event); } } @@ -931,11 +934,11 @@ void Application::migrateSettings() } -bool Application::notify( QObject *o, QEvent *e ) +bool Application::notify(QObject *object, QEvent *event) { try { - return QApplication::notify( o, e ); + return QApplication::notify(object, event); } catch( const digidoc::Exception &e ) { diff --git a/client/Application.h b/client/Application.h index 2de0881f1..dbad1f6ef 100644 --- a/client/Application.h +++ b/client/Application.h @@ -63,7 +63,7 @@ class Application final: public Common #endif void loadTranslation( const QString &lang ); QWidget* mainWindow(); - bool notify( QObject *o, QEvent *e ) override; + bool notify(QObject *object, QEvent *event ) final; void openHelp(); QSigner* signer() const; int run(); @@ -95,7 +95,7 @@ private Q_SLOTS: private: void activate( QWidget *w ); - bool event( QEvent *e ) override; + bool event(QEvent *event) final; void migrateSettings(); static void showWarning(const QString &msg, const digidoc::Exception &e); QWidget* uniqueRoot();