summaryrefslogtreecommitdiffstats
path: root/src/downloadManager.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-16 10:59:59 +0100
committerJonathan Bauer2011-03-16 10:59:59 +0100
commit3945ea6537a8f1c23c74c65b008a8d6079e873ab (patch)
tree9487cd7920916010d1dac3bce551a3fd91956b1c /src/downloadManager.cpp
parentmisc (diff)
downloadfbgui-3945ea6537a8f1c23c74c65b008a8d6079e873ab.tar.gz
fbgui-3945ea6537a8f1c23c74c65b008a8d6079e873ab.tar.xz
fbgui-3945ea6537a8f1c23c74c65b008a8d6079e873ab.zip
DM now appends download index to filename in case file already exists
Diffstat (limited to 'src/downloadManager.cpp')
-rw-r--r--src/downloadManager.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp
index 0262efe..9b44a3d 100644
--- a/src/downloadManager.cpp
+++ b/src/downloadManager.cpp
@@ -74,13 +74,21 @@ void downloadManager::startNextDownload()
tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1);
if (debug) qDebug() << "Extracted " << tmp << "from " << url.toString();
- outfile.setFileName(downloadPath + "/" + tmp);
- if (!outfile.open(QIODevice::WriteOnly))
- {
+ /* check if filename exists on target file system */
+ QFileInfo fi(downloadPath + "/" + tmp);
+ if (fi.exists()){
+ QString qs = QString(fi.absoluteFilePath() + ".\%1").arg(downloaded);
+ outfile.setFileName(qs);
+ }
+ else
+ outfile.setFileName(downloadPath + "/" + tmp);
+
+ if (!outfile.open(QIODevice::WriteOnly)){
if (debug) qDebug() << "Couldn't open file! Skipping...";
return;
}
-
+ QString qs = QString(fi.absoluteFilePath() + ".\%1").arg(downloaded);
+ qDebug() << "TEST:" << qs;
/* send the request for the file */
QNetworkRequest request(url);
currentDownload = qnam->get(request);
@@ -121,10 +129,12 @@ void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal)
QString unit;
if (speed < 1024) {
unit = "bytes/sec";
- } else if (speed < 1024*1024) {
+ }
+ else if (speed < 1024*1024) {
speed /= 1024;
unit = "KB/s";
- } else {
+ }
+ else {
speed /= 1024*1024;
unit = "MB/s";
}