diff options
Diffstat (limited to 'src/downloadManager.cpp')
| -rw-r--r-- | src/downloadManager.cpp | 22 |
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"; } |
