diff options
| author | Tannin <devnull@localhost> | 2013-02-22 19:28:54 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-02-22 19:28:54 +0100 |
| commit | 8b4e11060b37ad70754aa665ad59744eadd2dd1e (patch) | |
| tree | 3e0dd354a519a6c6af18fe6d233d03fdb1f6ca62 /src/installationmanager.cpp | |
| parent | cb297d20b616e49803470396c21dd5747370cfaf (diff) | |
- bugfix: update on overwrite directory leads files incorrectly being assigned to it
- bugfix: getfullpathname reroute now correctly handles relative paths
- bugfix: cwd change to overwrite is now handled too
- bugfix: using the external fomod installer to merge a mod caused error messages because directories couldn't be renamed
- bugfix: The memory for file dialogs wasn't saved to the ini file
- file category (main, update, optional, old) is now stored with the download for future use
- when overwriting a mod, the version of the mod is only increased, never reduced. This is less correct
for the unusual case that the user is downgrading but more correct for the more commen case
he is installing an optional file with incorrect version number
- the install mod dialog now uses the file dialog memory
Diffstat (limited to 'src/installationmanager.cpp')
| -rw-r--r-- | src/installationmanager.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index b1b7ff6c..27dfea6e 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -26,7 +26,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "fomodinstallerdialog.h" #include "report.h" #include "categories.h" -#include <scopeguard.h> #include "questionboxmemory.h" #include "settings.h" #include "queryoverwritedialog.h" @@ -35,8 +34,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "iplugininstallercustom.h" #include "nexusinterface.h" #include "selectiondialog.h" +#include <scopeguard.h> #include <installationtester.h> #include <gameinfo.h> +#include <utility.h> #include <QFileInfo> #include <QLibrary> #include <QInputDialog> @@ -625,7 +626,9 @@ bool InstallationManager::doInstall(const QString &modsDirectory, QString &modNa if ((modID != 0) || !settingsFile.contains("modid")) { settingsFile.setValue("modid", modID); } - if (!version.isEmpty() || !settingsFile.contains("version")) { + if (!settingsFile.contains("version") || + (!version.isEmpty() && + (VersionInfo(version) >= VersionInfo(settingsFile.value("version").toString())))) { settingsFile.setValue("version", version); } if (!newestVersion.isEmpty() || !settingsFile.contains("newestVersion")) { @@ -800,7 +803,7 @@ bool InstallationManager::installFomodExternal(const QString &fileName, const QS QFile::copy(QDir::fromNativeSeparators(ToQString(gameInfo.getGameDirectory().append(L"\\").append(gameInfo.getBinaryName()))), binaryDestination); - ON_BLOCK_EXIT([&binaryDestination] { QFile::remove(binaryDestination); } ); + ON_BLOCK_EXIT([&binaryDestination] { if (!QFile::remove(binaryDestination)) qCritical("failed to remove %s", qPrintable(binaryDestination)); } ); SHELLEXECUTEINFOW execInfo = {0}; execInfo.cbSize = sizeof(SHELLEXECUTEINFOW); @@ -851,28 +854,31 @@ bool InstallationManager::installFomodExternal(const QString &fileName, const QS ::CloseHandle(execInfo.hProcess); - if ((exitCode == 0) || (exitCode == 10)) { // 0 = success, 10 = incomplete installation bool errorOccured = false; { // move all installed files from the data directory one directory up - QDirIterator dirIter(QDir(modDirectory).absoluteFilePath("Data"), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + QDir targetDir(modDirectory); + + QDirIterator dirIter(targetDir.absoluteFilePath("Data"), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); bool hasFiles = false; + while (dirIter.hasNext()) { dirIter.next(); QFileInfo fileInfo = dirIter.fileInfo(); - - QDir dir(fileInfo.absolutePath()); - dir.cdUp(); - QString newName = dir.absoluteFilePath(fileInfo.fileName()); - if (QFile::exists(newName)) { + QString newName = targetDir.absoluteFilePath(fileInfo.fileName()); + if (fileInfo.isFile() && QFile::exists(newName)) { if (!QFile::remove(newName)) { qCritical("failed to overwrite %s", qPrintable(newName)); errorOccured = true; } - } + } // if it's a directory and the target exists that isn't really a problem + if (!QFile::rename(fileInfo.absoluteFilePath(), newName)) { - qCritical("failed to move %s to %s", qPrintable(fileInfo.absoluteFilePath()), qPrintable(newName)); - errorOccured = true; + // moving doesn't work when merging + if (!copyDir(fileInfo.absoluteFilePath(), newName, true)) { + qCritical("failed to move %s to %s", qPrintable(fileInfo.absoluteFilePath()), qPrintable(newName)); + errorOccured = true; + } } hasFiles = true; } @@ -1110,7 +1116,9 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin if ((modID != 0) || !settingsFile.contains("modid")) { settingsFile.setValue("modid", modID); } - if (!version.isEmpty() || !settingsFile.contains("version")) { + if (!settingsFile.contains("version") || + (!version.isEmpty() && + (VersionInfo(version) >= VersionInfo(settingsFile.value("version").toString())))) { settingsFile.setValue("version", version); } if (!newestVersion.isEmpty() || !settingsFile.contains("newestVersion")) { |
