summaryrefslogtreecommitdiffstats
path: root/src/DownloadManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DownloadManager.cpp')
-rw-r--r--src/DownloadManager.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp
index ce0e82a..7ab9333 100644
--- a/src/DownloadManager.cpp
+++ b/src/DownloadManager.cpp
@@ -1,4 +1,5 @@
#include "DownloadManager.h"
+//#include <QDir>
int DownloadManager::downloaded = 0;
// ----------------------------------------------------------------------------------------
@@ -46,8 +47,10 @@ void DownloadManager::startNextDownload()
// Get filename from URL.
QString tmp = url.path();
tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1);
- outfile.setFileName(downloadDirectory.path() + "/" + tmp);
- if (debug) qDebug() << "DM: Absolute path: " << downloadDirectory.path() + "/" + tmp;
+ if (debug) qDebug() << "Extracted " << tmp << "from " << url.toString();
+ // TODO: check for if relative path, if so prepend binPath
+ outfile.setFileName(downloadPath + "/" + tmp);
+ if (debug) qDebug() << "DM: Absolute path: " << downloadPath + "/" + tmp;
if (outfile.exists()){
if (debug) qDebug() << "File already exists. Skipping: " << url.toString();
startNextDownload();
@@ -122,4 +125,14 @@ DownloadManager::DownloadManager()
{
qnam = new QNetworkAccessManager();
dip = false;
+ downloadDir = QDir(downloadPath);
+ // Check if downloadPath exists, if not create it.
+ if (!downloadDir.exists()){
+ if (debug) qDebug() << downloadDir.path() << "doesn't exist.";
+ QDir::current().mkdir(downloadPath);
+ }
+ qDebug() << "1";
+ if (downloadDir.exists() && debug) qDebug() << "Created download directory: " << downloadPath;
+
+
}