From 137022b7f0e2f38f3f517fd34954b3518114c920 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 8 Mar 2011 13:17:12 +0100 Subject: first downloadDir fix --- src/DownloadManager.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/DownloadManager.cpp') 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 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; + + } -- cgit v1.2.3-55-g7522