refactor: move "delete old update files" logic to Updates (#5535)
This commit is contained in:
@@ -59,6 +59,7 @@
|
|||||||
- Dev: `FlagsEnum` is now `constexpr`. (#5510)
|
- Dev: `FlagsEnum` is now `constexpr`. (#5510)
|
||||||
- Dev: Documented and added tests to RTL handling. (#5473)
|
- Dev: Documented and added tests to RTL handling. (#5473)
|
||||||
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
|
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
|
||||||
|
- Dev: Refactored code that's responsible for deleting old update files. (#5535)
|
||||||
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
|
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
|
||||||
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)
|
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)
|
||||||
|
|
||||||
|
|||||||
+1
-16
@@ -241,22 +241,7 @@ void runGui(QApplication &a, const Paths &paths, Settings &settings,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto thread = std::thread([dir = paths.miscDirectory] {
|
updates.deleteOldFiles();
|
||||||
{
|
|
||||||
auto path = combinePath(dir, "Update.exe");
|
|
||||||
if (QFile::exists(path))
|
|
||||||
{
|
|
||||||
QFile::remove(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
auto path = combinePath(dir, "update.zip");
|
|
||||||
if (QFile::exists(path))
|
|
||||||
{
|
|
||||||
QFile::remove(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear the cache 1 minute after start.
|
// Clear the cache 1 minute after start.
|
||||||
QTimer::singleShot(60 * 1000, [cachePath = paths.cacheDirectory(),
|
QTimer::singleShot(60 * 1000, [cachePath = paths.cacheDirectory(),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QtConcurrent>
|
||||||
#include <semver/semver.hpp>
|
#include <semver/semver.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -40,9 +41,9 @@ const QString CHATTERINO_OS = u"freebsd"_s;
|
|||||||
#else
|
#else
|
||||||
const QString CHATTERINO_OS = u"unknown"_s;
|
const QString CHATTERINO_OS = u"unknown"_s;
|
||||||
#endif
|
#endif
|
||||||
;
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
Updates::Updates(const Paths &paths_)
|
Updates::Updates(const Paths &paths_)
|
||||||
@@ -75,6 +76,26 @@ bool Updates::isDowngradeOf(const QString &online, const QString ¤t)
|
|||||||
return onlineVersion < currentVersion;
|
return onlineVersion < currentVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Updates::deleteOldFiles()
|
||||||
|
{
|
||||||
|
std::ignore = QtConcurrent::run([dir{this->paths.miscDirectory}] {
|
||||||
|
{
|
||||||
|
auto path = combinePath(dir, "Update.exe");
|
||||||
|
if (QFile::exists(path))
|
||||||
|
{
|
||||||
|
QFile::remove(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto path = combinePath(dir, "update.zip");
|
||||||
|
if (QFile::exists(path))
|
||||||
|
{
|
||||||
|
QFile::remove(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const QString &Updates::getCurrentVersion() const
|
const QString &Updates::getCurrentVersion() const
|
||||||
{
|
{
|
||||||
return currentVersion_;
|
return currentVersion_;
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public:
|
|||||||
|
|
||||||
static bool isDowngradeOf(const QString &online, const QString ¤t);
|
static bool isDowngradeOf(const QString &online, const QString ¤t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delete old files that belong to the update process
|
||||||
|
*/
|
||||||
|
void deleteOldFiles();
|
||||||
|
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
const QString &getCurrentVersion() const;
|
const QString &getCurrentVersion() const;
|
||||||
const QString &getOnlineVersion() const;
|
const QString &getOnlineVersion() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user