diff --git a/NEWS.md b/NEWS.md index 276b818d4..84469959f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -28,7 +28,8 @@ ## Bug fixes * GUI: the cache cleanup process that's run automatically when the GUI starts - no longer blocks file identification until it is finished. Fixes #1860. + no longer blocks file identification until it is finished. Additionally the + process will only be run once per release of MKVToolNix. Fixes #1860. * GUI: certain failures during file identification that can be traced to broken installations (e.g. mkvmerge being too old) won't be stored in the cache anymore. Without this fix the GUI would still use the cached failed diff --git a/src/mkvtoolnix-gui/main_window/main_window.cpp b/src/mkvtoolnix-gui/main_window/main_window.cpp index d1db7c200..633b4c318 100644 --- a/src/mkvtoolnix-gui/main_window/main_window.cpp +++ b/src/mkvtoolnix-gui/main_window/main_window.cpp @@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) new TaskbarProgress{this}; #endif - QtConcurrent::run(Util::Cache::cleanOldCacheFiles); + runCacheCleanupOncePerVersion(); Util::InstallationChecker::checkInstallation(); } @@ -608,4 +608,12 @@ MainWindow::displayInstallationProblems(Util::InstallationChecker::Problems cons .exec(); } +void +MainWindow::runCacheCleanupOncePerVersion() + const { + Util::Settings::runOncePerVersion(Q("cacheCleanup"), []() { + QtConcurrent::run(Util::Cache::cleanOldCacheFiles); + }); +} + }} diff --git a/src/mkvtoolnix-gui/main_window/main_window.h b/src/mkvtoolnix-gui/main_window/main_window.h index 9600d3f86..9ab0007b8 100644 --- a/src/mkvtoolnix-gui/main_window/main_window.h +++ b/src/mkvtoolnix-gui/main_window/main_window.h @@ -126,6 +126,7 @@ protected: virtual boost::optional filterWheelEventForStrongFocus(QObject *watched, QEvent *event); virtual void silentlyCheckForUpdates(); + virtual void runCacheCleanupOncePerVersion() const; }; }} diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index 11ddbd7f2..11069279e 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -619,4 +619,23 @@ Settings::lastOpenDirPath() return Util::dirPath(m_lastOpenDir); } +void +Settings::runOncePerVersion(QString const &topic, + std::function worker) { + auto reg = registry(); + auto key = Q("runOncePerVersion/%1").arg(topic); + + auto lastRunInVersion = reg->value(key).toString(); + auto lastRunInVersionNumber = version_number_t{to_utf8(lastRunInVersion)}; + auto currentVersionNumber = get_current_version(); + + if ( lastRunInVersionNumber.valid + && !(lastRunInVersionNumber < currentVersionNumber)) + return; + + reg->setValue(key, Q(currentVersionNumber.to_string())); + + worker(); +} + }}} diff --git a/src/mkvtoolnix-gui/util/settings.h b/src/mkvtoolnix-gui/util/settings.h index 3e0901421..234edb2cc 100644 --- a/src/mkvtoolnix-gui/util/settings.h +++ b/src/mkvtoolnix-gui/util/settings.h @@ -188,6 +188,8 @@ public: static void change(std::function worker); static std::unique_ptr registry(); + static void runOncePerVersion(QString const &topic, std::function worker); + static QString exeWithPath(QString const &exe); static void migrateFromRegistry();