summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-09-02 13:58:57 +0200
committerPetr Mrázek <peterix@gmail.com>2017-09-02 13:58:57 +0200
commitb8adbb9b73751b022b42180dcc213dc99be9765b (patch)
tree2bbd11f9176a7e7aed21a87a464df2a5a856f8e9
parent6381bfdb885def3e532ffae640bb55e5b249819c (diff)
downloadMultiMC-b8adbb9b73751b022b42180dcc213dc99be9765b.tar
MultiMC-b8adbb9b73751b022b42180dcc213dc99be9765b.tar.gz
MultiMC-b8adbb9b73751b022b42180dcc213dc99be9765b.tar.lz
MultiMC-b8adbb9b73751b022b42180dcc213dc99be9765b.tar.xz
MultiMC-b8adbb9b73751b022b42180dcc213dc99be9765b.zip
GH-1971 do not check filesystem boundaries when committing instances
The check wasn't very good and was breaking because it assumed uniform paths.
-rw-r--r--api/logic/FolderInstanceProvider.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/api/logic/FolderInstanceProvider.cpp b/api/logic/FolderInstanceProvider.cpp
index ea0d4ef0..88b5bdc6 100644
--- a/api/logic/FolderInstanceProvider.cpp
+++ b/api/logic/FolderInstanceProvider.cpp
@@ -327,17 +327,14 @@ QString FolderInstanceProvider::getStagedInstancePath()
bool FolderInstanceProvider::commitStagedInstance(const QString& keyPath, const QString& path, const QString& instanceName,
const QString& groupName)
{
- if(!path.contains(keyPath))
- {
- qWarning() << "It is not possible to commit" << path << "because it is not in" << keyPath;
- return false;
- }
QDir dir;
QString instID = FS::DirNameFromString(instanceName, m_instDir);
{
WatchLock lock(m_watcher, m_instDir);
- if(!dir.rename(path, FS::PathCombine(m_instDir, instID)))
+ QString destination = FS::PathCombine(m_instDir, instID);
+ if(!dir.rename(path, destination))
{
+ qWarning() << "Failed to move" << path << "to" << destination;
destroyStagingPath(keyPath);
return false;
}