summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/downloadfiletask_p.h
diff options
context:
space:
mode:
authorkh <karsten.heimrich@theqtcompany.com>2015-04-20 16:40:21 +0200
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-04-24 09:06:16 +0000
commitcfc1f596760c1997b39bdfe8a43b4089da685988 (patch)
treecad5698471fa26f4b2a5420904857e3e4219506a /src/libs/installer/downloadfiletask_p.h
parente2a30c0c183bdeeda5d44d35e48b4e8ceee39cf3 (diff)
Fix "Too many open files" error.
The current code did create all files in advance, exceeding the open file limit on big downloads. Now we create the file once we write to it. Task-number: QTIFW-662 Change-Id: I9fe019e08342cbfb14bf564ad00b045cc03b6661 Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/downloadfiletask_p.h')
-rw-r--r--src/libs/installer/downloadfiletask_p.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/libs/installer/downloadfiletask_p.h b/src/libs/installer/downloadfiletask_p.h
index d91d335b3..a2f2969aa 100644
--- a/src/libs/installer/downloadfiletask_p.h
+++ b/src/libs/installer/downloadfiletask_p.h
@@ -36,30 +36,40 @@
#define DOWNLOADFILETASK_P_H
#include "downloadfiletask.h"
+#include <observer.h>
+#include <QFile>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
+#include <memory>
+#include <unordered_map>
+
QT_BEGIN_NAMESPACE
-class QFile;
class QSslError;
QT_END_NAMESPACE
namespace QInstaller {
-class FileTaskObserver;
-
struct Data
{
+ Q_DISABLE_COPY(Data)
+
Data()
- : file(0), observer(0) {}
- Data(QFile *f, FileTaskObserver *o, const FileTaskItem &fti)
- : file(f), observer(o), taskItem(fti)
+ : file(Q_NULLPTR)
+ , observer(Q_NULLPTR)
{}
- QFile *file;
- FileTaskObserver *observer;
+
+ Data(const FileTaskItem &fti)
+ : taskItem(fti)
+ , file(Q_NULLPTR)
+ , observer(new FileTaskObserver(QCryptographicHash::Sha1))
+ {}
+
FileTaskItem taskItem;
+ std::unique_ptr<QFile> file;
+ std::unique_ptr<FileTaskObserver> observer;
};
class Downloader : public QObject
@@ -98,8 +108,8 @@ private:
int m_finished;
QNetworkAccessManager m_nam;
QList<FileTaskItem> m_items;
- QHash<QNetworkReply*, Data> m_downloads;
QMultiHash<QNetworkReply*, QUrl> m_redirects;
+ std::unordered_map<QNetworkReply*, std::unique_ptr<Data>> m_downloads;
};
} // namespace QInstaller