aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCopyTask.cpp
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2023-06-14 20:05:02 +0100
committerGitHub <noreply@github.com>2023-06-14 20:05:02 +0100
commit3526d00a2330aad7d01f345816505c4d1cd5b096 (patch)
tree31b34c829f21ef6f49bc3dda6bd1fc6b55ac7029 /launcher/InstanceCopyTask.cpp
parent79ce7eb1fc9351e689e7106e3dc3a641d9614c9a (diff)
parenta4502f44c291fad2174e84bf883cdb754aa08e28 (diff)
downloadPrismLauncher-3526d00a2330aad7d01f345816505c4d1cd5b096.tar.gz
PrismLauncher-3526d00a2330aad7d01f345816505c4d1cd5b096.tar.bz2
PrismLauncher-3526d00a2330aad7d01f345816505c4d1cd5b096.zip
Merge branch 'develop' into feat/dont-hide-settings
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/InstanceCopyTask.cpp')
-rw-r--r--launcher/InstanceCopyTask.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/launcher/InstanceCopyTask.cpp b/launcher/InstanceCopyTask.cpp
index 4ac3b51a..57a3143a 100644
--- a/launcher/InstanceCopyTask.cpp
+++ b/launcher/InstanceCopyTask.cpp
@@ -39,7 +39,16 @@ void InstanceCopyTask::executeTask()
setStatus(tr("Copying instance %1").arg(m_origInstance->name()));
auto copySaves = [&]() {
- FS::copy savesCopy(FS::PathCombine(m_origInstance->instanceRoot(), "saves"), FS::PathCombine(m_stagingPath, "saves"));
+ QFileInfo mcDir(FS::PathCombine(m_stagingPath, "minecraft"));
+ QFileInfo dotMCDir(FS::PathCombine(m_stagingPath, ".minecraft"));
+
+ QString staging_mc_dir;
+ if (mcDir.exists() && !dotMCDir.exists())
+ staging_mc_dir = mcDir.filePath();
+ else
+ staging_mc_dir = dotMCDir.filePath();
+
+ FS::copy savesCopy(FS::PathCombine(m_origInstance->gameRoot(), "saves"), FS::PathCombine(staging_mc_dir, "saves"));
savesCopy.followSymlinks(true);
return savesCopy();
@@ -123,6 +132,7 @@ void InstanceCopyTask::copyFinished()
emitFailed(tr("Instance folder copy failed."));
return;
}
+
// FIXME: shouldn't this be able to report errors?
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
@@ -134,6 +144,24 @@ void InstanceCopyTask::copyFinished()
}
if (m_useLinks)
inst->addLinkedInstanceId(m_origInstance->id());
+ if (m_useLinks) {
+ auto allowed_symlinks_file = QFileInfo(FS::PathCombine(inst->gameRoot(), "allowed_symlinks.txt"));
+
+ QByteArray allowed_symlinks;
+ if (allowed_symlinks_file.exists()) {
+ allowed_symlinks.append(FS::read(allowed_symlinks_file.filePath()));
+ if (allowed_symlinks.right(1) != "\n")
+ allowed_symlinks.append("\n"); // we want to be on a new line
+ }
+ allowed_symlinks.append(m_origInstance->gameRoot().toUtf8());
+ allowed_symlinks.append("\n");
+ if (allowed_symlinks_file.isSymLink())
+ FS::deletePath(allowed_symlinks_file
+ .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link.
+
+ FS::write(allowed_symlinks_file.filePath(), allowed_symlinks);
+ }
+
emitSucceeded();
}