Commit 5fe22ac4 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

try to ensure we still remove old files

parent 4c25d449
......@@ -144,10 +144,15 @@ void KateExternalToolsPlugin::removeTools(const std::vector<KateExternalTool *>
continue;
}
QString configFile = KateExternalTool::configFileName(tool->name);
if (!configFile.isEmpty()) {
if (QString configFile = KateExternalTool::configFileName(tool->name); !configFile.isEmpty()) {
QFile::remove(toolsConfigDir() + configFile);
}
// remove old name variant, too
if (QString configFile = KateExternalTool::configFileNameOldStyleOnlyForRemove(tool->name); !configFile.isEmpty()) {
QFile::remove(toolsConfigDir() + configFile);
}
delete tool;
}
......@@ -169,6 +174,10 @@ void KateExternalToolsPlugin::save(KateExternalTool *tool, const QString &oldNam
if (!oldName.isEmpty()) {
const QString oldFile = toolsConfigDir() + KateExternalTool::configFileName(oldName);
QFile::remove(oldFile);
// remove old variant, too
const QString oldFile2 = toolsConfigDir() + KateExternalTool::configFileNameOldStyleOnlyForRemove(oldName);
QFile::remove(oldFile2);
}
}
......
......@@ -130,7 +130,23 @@ public:
static QString configFileName(QString name)
{
// just percent encode the name, see bug 453272
return QString::fromUtf8(QUrl::toPercentEncoding(name));
// we add a special suffix to not clash with old files, old files were all lowercase
return QStringLiteral("PE_") + QString::fromUtf8(QUrl::toPercentEncoding(name));
}
/**
* OLD names: we need this to cleanup!
* Returns the config file name for this tool, created based on the tool "name", e.g.
* "Clang Format Full File" -> clang_format_full_file
* this will be the name of the config file in e.g. ~/.config/kate/externaltools/
*/
static QString configFileNameOldStyleOnlyForRemove(QString name)
{
name.replace(QLatin1Char(' '), QLatin1Char('_'));
// '(' and ')' are problematic as file names in the .qrc file
name.replace(QLatin1Char('('), QLatin1Char('_'));
name.replace(QLatin1Char(')'), QLatin1Char('_'));
return name.toLower();
}
};
......
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