From dd7d35a216ff399f71a01c8e5d98f1cc22a34edf Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 23 Mar 2011 15:09:07 +0100 Subject: download manager directory checks improvements... --- src/downloadmanager.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index ab1b0ad..ae7504d 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -10,34 +10,40 @@ DownloadManager::DownloadManager(){ dip = false; } // ---------------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------------- void DownloadManager::checkDownloadDirectory() { // check if downloadPath exists, if not create it. downloadDir = QDir(downloadPath); if (!downloadDir.exists()){ qxtLog->debug() << "Download directory: " << downloadDir.path() << " doesn't exist."; - QDir::current().mkdir(downloadPath); - if (downloadDir.exists()){ + // try to create the directory + if (QDir::current().mkdir(downloadPath)) qxtLog->debug() << "Created download directory: " << downloadDir.path(); - } else { qxtLog->debug() << "Failed to create directory: " << downloadDir.path(); // try to save to /tmp/fbgui downloadDir.setPath(QDir::tempPath () + "/fbgui"); if (!downloadDir.exists()){ - QDir::current().mkdir(QDir::tempPath () + "/fbgui"); - if (!downloadDir.exists()){ - // TODO: dont exit, this shouldn't happen anyway (right?) - qxtLog->debug() << "Fatal, no target for downloads. Exiting..."; + if (QDir::current().mkdir(QDir::tempPath () + "/fbgui")) + qxtLog->debug() << "Successfully created: " << downloadDir.absolutePath(); + else { + // just in case + qxtLog->debug() << "Failed to create: " << downloadDir.absolutePath(); + qxtLog->debug() << "Exiting..."; exit(EXIT_FAILURE); } } - qxtLog->debug() << "Saving downloads to: " << downloadDir.absolutePath(); + else + qxtLog->debug() << downloadDir.absolutePath() << " already exists."; } } - else qxtLog->debug() << "Download directory: " << downloadDir.path() << " exists."; + else + qxtLog->debug() << "Download directory: " << downloadDir.absolutePath() << " already exists."; + + qxtLog->debug() << "Saving downloads to: " << downloadDir.absolutePath(); + //downloadPath = downloadDir.absolutePath(); } -// ---------------------------------------------------------------------------------------- void DownloadManager::downloadFile(const QString& filename) { QUrl fileUrl(baseURL.resolved(QUrl(filename))); -- cgit v1.2.3-55-g7522