Skip to content

Commit

Permalink
Migrate old conf file to new location on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jNullj committed Aug 18, 2023
1 parent b8bcf23 commit 9845079
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,21 @@ void Config::init(const QString& configFileName, const QString& localConfigFileN
QDir().rmdir(QFileInfo(localConfigFileName).absolutePath());
}

#if defined(Q_OS_LINUX)
// 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";
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());
}
#endif

m_settings.reset(new QSettings(configFileName, QSettings::IniFormat));
if (!localConfigFileName.isEmpty() && configFileName != localConfigFileName) {
m_localSettings.reset(new QSettings(localConfigFileName, QSettings::IniFormat));
Expand Down

0 comments on commit 9845079

Please sign in to comment.