diff --git a/app/batchextract.cpp b/app/batchextract.cpp
index 3ea90bd..fec7bc1 100644
--- a/app/batchextract.cpp
+++ b/app/batchextract.cpp
@@ -67,9 +67,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::suggestName(QUrl::fromUserInput(destination, QString(), QUrl::AssumeLocalFile), subfolderName);
diff --git a/kerfuffle/archive_kerfuffle.cpp b/kerfuffle/archive_kerfuffle.cpp
index 7b9990d..0ed2c1f 100644
--- a/kerfuffle/archive_kerfuffle.cpp
+++ b/kerfuffle/archive_kerfuffle.cpp
@@ -209,6 +209,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
@@ -230,15 +240,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/archive_kerfuffle.h b/kerfuffle/archive_kerfuffle.h
index f6fbbd8..488e650 100644
--- a/kerfuffle/archive_kerfuffle.h
+++ b/kerfuffle/archive_kerfuffle.h
@@ -97,6 +97,7 @@ public:
~Archive();
QString fileName() const;
+ QString fileBaseName() const;
bool isReadOnly() const;
KJob* open();
diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp
index 3dabb4e..1c0f15d 100644
--- a/kerfuffle/jobs.cpp
+++ b/kerfuffle/jobs.cpp
@@ -225,7 +225,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::fromLatin1("^\\./")), QString()));
const QString basePath(fileName.split(QLatin1Char( '/' )).at(0));
if (m_basePath.isEmpty()) {