Commit b6a1b247 authored by Eastern Li's avatar Eastern Li
Browse files

Don't append surplus '.' when `suffix` is empty.

Since the filename is not completed, also not detect if it exists.
This will happen when using Dolphin's right-click service menu.
parent 0c90f1e9
......@@ -251,17 +251,15 @@ QString AddToArchive::getFileNameForUrls(const QList<QUrl> &urls, const QString
base.chop(4);
}
QString finalName = base + QLatin1Char('.') + suffix;
// if file already exists, append a number to the base until it doesn't
// exist
int appendNumber = 0;
const QString path = fileInfo.absolutePath() + QStringLiteral("/");
while (QFileInfo::exists(path + finalName)) {
++appendNumber;
finalName = KFileUtils::makeSuggestedName(finalName);
}
if (suffix.isEmpty()) {
return path + base;
}
QString finalName = base + QLatin1Char('.') + suffix;
if (QFileInfo::exists(path + finalName)) {
finalName = KFileUtils::suggestName(QUrl::fromLocalFile(path), finalName);
}
return path + finalName;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment