aboutsummaryrefslogtreecommitdiff
path: root/launcher/Application.cpp
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-28 11:25:58 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-11 21:42:29 -0700
commit9957aeb003a28f24a7d3b2bbc46d21c31506615d (patch)
tree891048851c7819f334abf384a7d99dbeec7bf0ea /launcher/Application.cpp
parenteb079c80605f88cbd0aaff8285dafc459c6f42eb (diff)
parent640aaa8c23d714ce17bc8e78754af6219abc6466 (diff)
downloadPrismLauncher-9957aeb003a28f24a7d3b2bbc46d21c31506615d.tar.gz
PrismLauncher-9957aeb003a28f24a7d3b2bbc46d21c31506615d.tar.bz2
PrismLauncher-9957aeb003a28f24a7d3b2bbc46d21c31506615d.zip
Merge branch 'develop' into curseforge-url-handle
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r--launcher/Application.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index edaccadf..354ba440 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -377,33 +377,33 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// init the logger
{
- static const QString logBase = BuildConfig.LAUNCHER_NAME + "-%0.log";
- auto moveFile = [](const QString &oldName, const QString &newName)
- {
+ static const QString baseLogFile = BuildConfig.LAUNCHER_NAME + "-%0.log";
+ static const QString logBase = FS::PathCombine("logs", baseLogFile);
+ auto moveFile = [](const QString& oldName, const QString& newName) {
QFile::remove(newName);
QFile::copy(oldName, newName);
QFile::remove(oldName);
};
+ if (FS::ensureFolderPathExists("logs")) { // if this did not fail
+ for (auto i = 0; i <= 4; i++)
+ if (auto oldName = baseLogFile.arg(i);
+ QFile::exists(oldName)) // do not pointlessly delete new files if the old ones are not there
+ moveFile(oldName, logBase.arg(i));
+ }
- moveFile(logBase.arg(3), logBase.arg(4));
- moveFile(logBase.arg(2), logBase.arg(3));
- moveFile(logBase.arg(1), logBase.arg(2));
- moveFile(logBase.arg(0), logBase.arg(1));
+ for (auto i = 4; i > 0; i--)
+ moveFile(logBase.arg(i - 1), logBase.arg(i));
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
- if(!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
- {
- showFatalErrorMessage(
- "The launcher data folder is not writable!",
- QString(
- "The launcher couldn't create a log file - the data folder is not writable.\n"
- "\n"
- "Make sure you have write permissions to the data folder.\n"
- "(%1)\n"
- "\n"
- "The launcher cannot continue until you fix this problem."
- ).arg(dataPath)
- );
+ if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
+ showFatalErrorMessage("The launcher data folder is not writable!",
+ QString("The launcher couldn't create a log file - the data folder is not writable.\n"
+ "\n"
+ "Make sure you have write permissions to the data folder.\n"
+ "(%1)\n"
+ "\n"
+ "The launcher cannot continue until you fix this problem.")
+ .arg(dataPath));
return;
}
qInstallMessageHandler(appDebugOutput);
@@ -595,7 +595,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// Java Settings
m_settings->registerSetting("JavaPath", "");
- m_settings->registerSetting("JavaTimestamp", 0);
+ m_settings->registerSetting("JavaSignature", "");
m_settings->registerSetting("JavaArchitecture", "");
m_settings->registerSetting("JavaRealArchitecture", "");
m_settings->registerSetting("JavaVersion", "");
@@ -688,8 +688,16 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->reset("PastebinCustomAPIBase");
}
}
- // meta URL
- m_settings->registerSetting("MetaURLOverride", "");
+ {
+ // Meta URL
+ m_settings->registerSetting("MetaURLOverride", "");
+
+ QUrl metaUrl(m_settings->get("MetaURLOverride").toString());
+
+ // get rid of invalid meta urls
+ if (!metaUrl.isValid() || metaUrl.scheme() != "http" || metaUrl.scheme() != "https")
+ m_settings->reset("MetaURLOverride");
+ }
m_settings->registerSetting("CloseAfterLaunch", false);
m_settings->registerSetting("QuitAfterGameStop", false);
@@ -1692,6 +1700,7 @@ bool Application::handleDataMigration(const QString& currentData,
matcher->add(std::make_shared<SimplePrefixMatcher>(configFile));
matcher->add(std::make_shared<SimplePrefixMatcher>(
BuildConfig.LAUNCHER_CONFIGFILE)); // it's possible that we already used that directory before
+ matcher->add(std::make_shared<SimplePrefixMatcher>("logs/"));
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts.json"));
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts/"));
matcher->add(std::make_shared<SimplePrefixMatcher>("assets/"));