Blame SOURCES/ark-4.9.97-improve_subfolder_autodetection.patch

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