Blob Blame History Raw
diff --git a/app/batchextract.cpp b/app/batchextract.cpp
index 9e466350568384247e99362745205c417b27873f..86f946b18f94f83b42d4bcd0bc320e6a5a3e7e64 100644
--- a/app/batchextract.cpp
+++ b/app/batchextract.cpp
@@ -68,9 +68,9 @@ void BatchExtract::addExtraction(Kerfuffle::Archive* archive)
 {
     QString destination = destinationFolder();
 
-    if ((autoSubfolder()) && (!archive->isSingleFolderArchive())) {
+    if ((autoSubfolder()) && (!archive->isSingleFolderArchive() || !archive->fileBaseName().startsWith(archive->subfolderName()))) {
         const QDir d(destination);
-        QString subfolderName = archive->subfolderName();
+        QString subfolderName = archive->fileBaseName();
 
         if (d.exists(subfolderName)) {
             subfolderName = KIO::RenameDialog::suggestName(destination, subfolderName);
diff --git a/kerfuffle/archive.h b/kerfuffle/archive.h
index 515788f978c1d29146c25dcb57a9dad2d46371f7..38049f2c949eb2ab804fc61f9da9336e6e848b77 100644
--- a/kerfuffle/archive.h
+++ b/kerfuffle/archive.h
@@ -95,6 +95,7 @@ public:
     ~Archive();
 
     QString fileName() const;
+    QString fileBaseName() const;
     bool isReadOnly() const;
 
     KJob* open();
diff --git a/kerfuffle/archive.cpp b/kerfuffle/archive.cpp
index c2c5b18528def63405a8703475b1c592ca945973..470fc56879a2d5e579389b69591da9f230af74ea 100644
--- a/kerfuffle/archive.cpp
+++ b/kerfuffle/archive.cpp
@@ -196,6 +196,16 @@ QString Archive::fileName() const
     return m_iface->filename();
 }
 
+QString Archive::fileBaseName() const
+{
+    QString base = QFileInfo(m_iface->filename()).completeBaseName();
+    //special case for tar.gz/bzip2 files
+    if (base.right(4).toUpper() == QLatin1String(".TAR")) {
+        base.chop(4);
+    }
+    return base;
+}
+
 void Archive::onAddFinished(KJob* job)
 {
     //if the archive was previously a single folder archive and an add job
@@ -217,15 +227,7 @@ void Archive::onListFinished(KJob* job)
     m_isPasswordProtected = ljob->isPasswordProtected();
     m_subfolderName = ljob->subfolderName();
     if (m_subfolderName.isEmpty()) {
-        QFileInfo fi(fileName());
-        QString base = fi.completeBaseName();
-
-        //special case for tar.gz/bzip2 files
-        if (base.right(4).toUpper() == QLatin1String(".TAR")) {
-            base.chop(4);
-        }
-
-        m_subfolderName = base;
+        m_subfolderName = fileBaseName();
     }
 
     m_hasBeenListed = true;
diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp
index aedc62c4c9902c4f3207c648747f2e427446d5e5..de16439ce46283956e7741662bda19d1e8e591fa 100644
--- a/kerfuffle/jobs.cpp
+++ b/kerfuffle/jobs.cpp
@@ -217,7 +217,8 @@ void ListJob::onNewEntry(const ArchiveEntry& entry)
     m_isPasswordProtected |= entry [ IsPasswordProtected ].toBool();
 
     if (m_isSingleFolderArchive) {
-        const QString fileName(entry[FileName].toString());
+        const QString fileName(entry[FileName].toString()
+		             .replace(QRegExp(QString::fromAscii("^\\./")), QString()));
         const QString basePath(fileName.split(QLatin1Char( '/' )).at(0));
 
         if (m_basePath.isEmpty()) {