1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #1979 from IvanSavenko/fix_multiple_mods_install

Fix installation of multiple mods at once, e.g. during setup
This commit is contained in:
Ivan Savenko
2023-04-14 14:12:23 +03:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -20,12 +20,12 @@ CDownloadManager::CDownloadManager()
void CDownloadManager::downloadFile(const QUrl & url, const QString & file) void CDownloadManager::downloadFile(const QUrl & url, const QString & file)
{ {
filename = file;
QNetworkRequest request(url); QNetworkRequest request(url);
FileEntry entry; FileEntry entry;
entry.file.reset(new QFile(CLauncherDirs::get().downloadsPath() + '/' + file)); entry.file.reset(new QFile(CLauncherDirs::get().downloadsPath() + '/' + file));
entry.bytesReceived = 0; entry.bytesReceived = 0;
entry.totalSize = 0; entry.totalSize = 0;
entry.filename = file;
if(entry.file->open(QIODevice::WriteOnly | QIODevice::Truncate)) if(entry.file->open(QIODevice::WriteOnly | QIODevice::Truncate))
{ {
@@ -68,10 +68,13 @@ void CDownloadManager::downloadFinished(QNetworkReply * reply)
if(possibleRedirectUrl.isValid()) if(possibleRedirectUrl.isValid())
{ {
QString filename;
for(int i = 0; i< currentDownloads.size(); ++i) for(int i = 0; i< currentDownloads.size(); ++i)
{ {
if(currentDownloads[i].file == file.file) if(currentDownloads[i].file == file.file)
{ {
filename = currentDownloads[i].filename;
currentDownloads.removeAt(i); currentDownloads.removeAt(i);
break; break;
} }

View File

@@ -29,6 +29,7 @@ class CDownloadManager : public QObject
QNetworkReply * reply; QNetworkReply * reply;
QSharedPointer<QFile> file; QSharedPointer<QFile> file;
QString filename;
Status status; Status status;
qint64 bytesReceived; qint64 bytesReceived;
qint64 totalSize; qint64 totalSize;
@@ -36,8 +37,6 @@ class CDownloadManager : public QObject
QStringList encounteredErrors; QStringList encounteredErrors;
QString filename;
QNetworkAccessManager manager; QNetworkAccessManager manager;
QList<FileEntry> currentDownloads; QList<FileEntry> currentDownloads;