summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-19 16:32:19 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-19 16:32:19 (GMT)
commitaacfc786ddb0098dc6fdda4a89e6f9133a542507 (patch)
tree54a7bc68d3fb46fa58697de365bf62f88dc8a557
parent47e45e73ea6d9559951b2e0dd2b8368b99f63749 (diff)
clizip: fix renaming files in the root
Renaming files in the root folder was broken with clizip. Test case was also missing. BUG: 368530 FIXED-IN: 16.12.0
-rw-r--r--autotests/kerfuffle/movetest.cpp7
-rw-r--r--plugins/clizipplugin/cliplugin.cpp7
2 files changed, 11 insertions, 3 deletions
diff --git a/autotests/kerfuffle/movetest.cpp b/autotests/kerfuffle/movetest.cpp
index 3f61fd5..d574f80 100644
--- a/autotests/kerfuffle/movetest.cpp
+++ b/autotests/kerfuffle/movetest.cpp
@@ -191,6 +191,13 @@ void MoveTest::testMoving_data()
QStringLiteral("dir/b.txt")
},
13);
+
+ setupRows(QStringLiteral("rename a file in the root (bug #368530)"),
+ QStringLiteral("test"),
+ QVector<Archive::Entry*> { new Archive::Entry(this, QStringLiteral("a.txt")) },
+ new Archive::Entry(this, QStringLiteral("new-name.txt")),
+ QStringList { QStringLiteral("new-name.txt") },
+ 13);
}
void MoveTest::testMoving()
diff --git a/plugins/clizipplugin/cliplugin.cpp b/plugins/clizipplugin/cliplugin.cpp
index 980b320..09bcd7f 100644
--- a/plugins/clizipplugin/cliplugin.cpp
+++ b/plugins/clizipplugin/cliplugin.cpp
@@ -277,7 +277,8 @@ bool CliPlugin::setMovingAddedFiles()
// We have to exclude file name from destination path in order to pass it to addFiles method.
const QString destinationPath = m_passedDestination->fullPath();
- if (!destinationPath.endsWith(QLatin1Char('/')) || destinationPath.count(QLatin1Char('/')) > 1) {
+ const int slashCount = destinationPath.count(QLatin1Char('/'));
+ if (slashCount > 1 || (slashCount == 1 && !destinationPath.endsWith(QLatin1Char('/')))) {
int destinationLength = destinationPath.count();
bool iteratedChar = false;
do {
@@ -287,8 +288,8 @@ bool CliPlugin::setMovingAddedFiles()
}
} while (destinationLength > 0 && !(iteratedChar && destinationPath.at(destinationLength) == QLatin1Char('/')));
m_passedDestination->setProperty("fullPath", destinationPath.left(destinationLength + 1));
- } else {
- // ...unless the destination path is already a single folder, e.g. "dir/".
+ } else {
+ // ...unless the destination path is already a single folder, e.g. "dir/", or a file, e.g. "foo.txt".
// In this case we're going to add to the root, so we just need to set a null destination.
m_passedDestination = Q_NULLPTR;
}