Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change conf path XDG_CACHE_HOME to XDG_STATE_HOME #9755

Merged
27 changes: 14 additions & 13 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,21 @@ void Config::init(const QString& configFileName, const QString& localConfigFileN
// Upgrade from previous KeePassXC version which stores its config
// in ~/.cache on Linux instead of ~/.local/state.
// Move file to correct location before continuing.
QString oldLocalConfigPath;
oldLocalConfigPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/keepassxc";
QString suffix;
if (!QFile::exists(localConfigFileName)) {
QString oldLocalConfigPath;
oldLocalConfigPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/keepassxc";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not separate declaration/definition and assignment. Rest looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 85a2b74

QString suffix;
#ifdef QT_DEBUG
suffix = "_debug";
suffix = "_debug";
#endif
oldLocalConfigPath += QString("/keepassxc%1.ini").arg(suffix);
oldLocalConfigPath = QDir::toNativeSeparators(oldLocalConfigPath);
if (!localConfigFileName.isEmpty() && !QFile::exists(localConfigFileName) && QFile::exists(oldLocalConfigPath)) {
QDir().mkpath(QFileInfo(localConfigFileName).absolutePath());
QFile::copy(oldLocalConfigPath, localConfigFileName);
QFile::remove(oldLocalConfigPath);
QDir().rmdir(QFileInfo(oldLocalConfigPath).absolutePath());
oldLocalConfigPath += QString("/keepassxc%1.ini").arg(suffix);
oldLocalConfigPath = QDir::toNativeSeparators(oldLocalConfigPath);
if (QFile::exists(oldLocalConfigPath)) {
QDir().mkpath(QFileInfo(localConfigFileName).absolutePath());
QFile::copy(oldLocalConfigPath, localConfigFileName);
QFile::remove(oldLocalConfigPath);
QDir().rmdir(QFileInfo(oldLocalConfigPath).absolutePath());
}
}
#endif

Expand Down Expand Up @@ -533,8 +535,7 @@ QPair<QString, QString> Config::defaultConfigFiles()
// On case-sensitive Operating Systems, force use of lowercase app directories
configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/keepassxc";
// Qt does not support XDG_STATE_HOME yet, change this once XDG_STATE_HOME is added
QString xdgStateHome;
xdgStateHome = QFile::decodeName(qgetenv("XDG_STATE_HOME"));
QString xdgStateHome = QFile::decodeName(qgetenv("XDG_STATE_HOME"));
if (!xdgStateHome.startsWith(u'/')) {
xdgStateHome.clear(); // spec says relative paths should be ignored
}
Expand Down