Blame ark-15.12.0-improve_subfolder_autodetection.patch

Rex Dieter 8a35a6
diff -up ark-15.12.0/app/batchextract.cpp.improve_subfolder_autodetection ark-15.12.0/app/batchextract.cpp
Rex Dieter 8a35a6
--- ark-15.12.0/app/batchextract.cpp.improve_subfolder_autodetection	2015-12-09 06:01:32.000000000 -0600
Rex Dieter 8a35a6
+++ ark-15.12.0/app/batchextract.cpp	2015-12-15 07:01:03.558096124 -0600
Rex Dieter 8a35a6
@@ -67,9 +67,9 @@ void BatchExtract::addExtraction(Kerfuff
Rex Dieter 0ba12b
 {
Rex Dieter 0ba12b
     QString destination = destinationFolder();
Rex Dieter 1a425c
 
Rex Dieter 0ba12b
-    if ((autoSubfolder()) && (!archive->isSingleFolderArchive())) {
Rex Dieter 0ba12b
+    if ((autoSubfolder()) && (!archive->isSingleFolderArchive() || !archive->fileBaseName().startsWith(archive->subfolderName()))) {
Rex Dieter 0ba12b
         const QDir d(destination);
Rex Dieter 0ba12b
-        QString subfolderName = archive->subfolderName();
Rex Dieter 0ba12b
+        QString subfolderName = archive->fileBaseName();
Rex Dieter 1a425c
 
Rex Dieter 0ba12b
         if (d.exists(subfolderName)) {
Dan Vrátil e62339
             subfolderName = KIO::suggestName(QUrl::fromUserInput(destination, QString(), QUrl::AssumeLocalFile), subfolderName);
Rex Dieter 8a35a6
diff -up ark-15.12.0/kerfuffle/archive_kerfuffle.cpp.improve_subfolder_autodetection ark-15.12.0/kerfuffle/archive_kerfuffle.cpp
Rex Dieter 8a35a6
--- ark-15.12.0/kerfuffle/archive_kerfuffle.cpp.improve_subfolder_autodetection	2015-12-09 06:01:32.000000000 -0600
Rex Dieter 8a35a6
+++ ark-15.12.0/kerfuffle/archive_kerfuffle.cpp	2015-12-15 07:01:03.558096124 -0600
Rex Dieter 8a35a6
@@ -292,6 +292,16 @@ QString Archive::fileName() const
Rex Dieter 1a425c
     return m_iface->filename();
Rex Dieter 1a425c
 }
Rex Dieter 1a425c
 
Rex Dieter 1a425c
+QString Archive::fileBaseName() const
Rex Dieter 1a425c
+{
Rex Dieter 1a425c
+    QString base = QFileInfo(m_iface->filename()).completeBaseName();
Rex Dieter 1a425c
+    //special case for tar.gz/bzip2 files
Rex Dieter 1a425c
+    if (base.right(4).toUpper() == QLatin1String(".TAR")) {
Rex Dieter 1a425c
+        base.chop(4);
Rex Dieter 1a425c
+    }
Rex Dieter 1a425c
+    return base;
Rex Dieter 1a425c
+}
Rex Dieter 1a425c
+
Rex Dieter 1a425c
 void Archive::onAddFinished(KJob* job)
Rex Dieter 1a425c
 {
Rex Dieter 1a425c
     //if the archive was previously a single folder archive and an add job
Rex Dieter 8a35a6
@@ -313,15 +323,7 @@ void Archive::onListFinished(KJob* job)
Rex Dieter 1a425c
     m_isPasswordProtected = ljob->isPasswordProtected();
Rex Dieter 1a425c
     m_subfolderName = ljob->subfolderName();
Rex Dieter 1a425c
     if (m_subfolderName.isEmpty()) {
Rex Dieter 1a425c
-        QFileInfo fi(fileName());
Rex Dieter 1a425c
-        QString base = fi.completeBaseName();
Rex Dieter 1a425c
-
Rex Dieter 1a425c
-        //special case for tar.gz/bzip2 files
Rex Dieter 1a425c
-        if (base.right(4).toUpper() == QLatin1String(".TAR")) {
Rex Dieter 1a425c
-            base.chop(4);
Rex Dieter 1a425c
-        }
Rex Dieter 1a425c
-
Rex Dieter 1a425c
-        m_subfolderName = base;
Rex Dieter 1a425c
+        m_subfolderName = fileBaseName();
Rex Dieter 1a425c
     }
Rex Dieter 1a425c
 
Rex Dieter 1a425c
     m_hasBeenListed = true;
Rex Dieter 8a35a6
diff -up ark-15.12.0/kerfuffle/archive_kerfuffle.h.improve_subfolder_autodetection ark-15.12.0/kerfuffle/archive_kerfuffle.h
Rex Dieter 8a35a6
--- ark-15.12.0/kerfuffle/archive_kerfuffle.h.improve_subfolder_autodetection	2015-12-15 07:01:03.558096124 -0600
Rex Dieter 8a35a6
+++ ark-15.12.0/kerfuffle/archive_kerfuffle.h	2015-12-15 07:02:45.776682176 -0600
Rex Dieter 8a35a6
@@ -149,6 +149,7 @@ public:
Rex Dieter 8a35a6
     ArchiveError error() const;
Rex Dieter 8a35a6
     bool isValid() const;
Dan Vrátil e62339
     QString fileName() const;
Dan Vrátil e62339
+    QString fileBaseName() const;
Dan Vrátil e62339
     bool isReadOnly() const;
Dan Vrátil e62339
 
Dan Vrátil e62339
     KJob* open();
Rex Dieter 8a35a6
diff -up ark-15.12.0/kerfuffle/jobs.cpp.improve_subfolder_autodetection ark-15.12.0/kerfuffle/jobs.cpp
Rex Dieter 8a35a6
--- ark-15.12.0/kerfuffle/jobs.cpp.improve_subfolder_autodetection	2015-12-09 06:01:32.000000000 -0600
Rex Dieter 8a35a6
+++ ark-15.12.0/kerfuffle/jobs.cpp	2015-12-15 07:01:03.559096130 -0600
Rex Dieter 8a35a6
@@ -226,7 +226,8 @@ void ListJob::onNewEntry(const ArchiveEn
Rex Dieter 0ba12b
     m_isPasswordProtected |= entry [ IsPasswordProtected ].toBool();
Rex Dieter 1a425c
 
Rex Dieter 0ba12b
     if (m_isSingleFolderArchive) {
Rex Dieter 0ba12b
-        const QString fileName(entry[FileName].toString());
Rex Dieter 0ba12b
+        const QString fileName(entry[FileName].toString()
Dan Vrátil e62339
+		             .replace(QRegExp(QString::fromLatin1("^\\./")), QString()));
Rex Dieter 0ba12b
         const QString basePath(fileName.split(QLatin1Char( '/' )).at(0));
Rex Dieter 1a425c
 
Rex Dieter 0ba12b
         if (m_basePath.isEmpty()) {