From 3afb0217d09a012c4a65740155b232c67fef4990 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:57:19 +0100 Subject: Fixed download system about downloading files with the same name. --- src/download.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index d1ed296a..e4ee556d 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -58,6 +58,13 @@ void Download::slotResult(KJob * job) { kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); QFile destFile(m_destUrl.path()); + int n = 1; + while( destFile.exists() ) + { + QString fn = QFile(m_destUrl.path()).fileName(); + destFile.setFileName( fn + "." + QString::number(n) ); + n++; + } if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) { destFile.write(m_data); @@ -69,7 +76,6 @@ void Download::slotResult(KJob * job) case KIO::ERR_FILE_ALREADY_EXIST: { kDebug(5001) << "ERROR - File already exists"; - // QFile file(m_destUrl.path()); m_data = 0; break; } -- cgit v1.2.1