summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DownloadManager.cpp20
-rw-r--r--src/fbbrowser.cpp1
2 files changed, 13 insertions, 8 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp
index bb43b04..dc2502f 100644
--- a/src/DownloadManager.cpp
+++ b/src/DownloadManager.cpp
@@ -13,7 +13,8 @@ void DownloadManager::processDownloadRequest(QString& filename)
// If download in progress, enqueue file and return.
if (dip)
{
- qDebug() << "Download in progress! Enqueueing:" << u.toString();
+ qDebug() << "Download in progress! Enqueueing:" << u.toString()
+ << "(" << dlQ.size() << "in queue)";
dlQ.enqueue(u);
return;
}
@@ -27,8 +28,7 @@ void DownloadManager::startNextDownload()
{
qDebug() << "Starting next download: " << dlQ.head().toString()
<< "(" << dlQ.size() << "in queue.)";
- // Set flag for download in progress.
- dip = true;
+
// TODO: needed ?
if (dlQ.isEmpty())
{
@@ -45,9 +45,6 @@ void DownloadManager::startNextDownload()
this->filename = "download";
else
this->filename = basename;
- //qDebug() << "Path is: " << path << endl;
- //qDebug() << "Basename is: " << basename << endl;
- //qDebug() << "Filename is: " << this->filename;
outfile.setFileName(this->filename);
// If error upon opening, skip this file.
if (!outfile.open(QIODevice::WriteOnly))
@@ -56,9 +53,16 @@ void DownloadManager::startNextDownload()
startNextDownload();
return;
}
+ qDebug() << "spot 1";
// Start the request for this URL.
QNetworkRequest request(url);
currentDownload = qnam->get(request);
+ if (currentDownload->error() != QNetworkReply::NoError)
+ {
+ qDebug() << "Network reply error, skipping download...";
+ return;
+ }
+ dip = true;
QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT(downloadReady()));
QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)),
this, SLOT(downloadProgress(qint64, qint64)));
@@ -96,13 +100,15 @@ void DownloadManager::downloadFinished()
outfile.close();
// If queue is empty, we are done.
// TODO: not sure if this is actually needed...
+ dip = false;
if (dlQ.isEmpty())
+ qDebug() << "dlQ empty! returning...";
return;
// Queue not empty.
+
// Delete current reply object.
currentDownload->deleteLater();
// Initialise next download.
- dip = false;
++downloaded;
// qDebug() << "DM downloaded " << downloaded << "files";
startNextDownload();
diff --git a/src/fbbrowser.cpp b/src/fbbrowser.cpp
index 7436c85..2b8bc7a 100644
--- a/src/fbbrowser.cpp
+++ b/src/fbbrowser.cpp
@@ -28,7 +28,6 @@ fbbrowser::fbbrowser(const QUrl & url)
// signal, haven't found a better way yet ...
if(reply->error() == QNetworkReply::NoError)
{
- //qDebug() << "No error, loading given URL...";
view->load(url);
}
else