From 2710bca395c1432a96976a6212e31a04efd28c92 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 9 Mar 2012 15:16:16 -0500 Subject: [PATCH] Back up old config file before upgrading, when it's an ini file --- src/libtomahawk/tomahawksettings.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index a8c664e18..8b93906dd 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -60,8 +60,22 @@ TomahawkSettings::TomahawkSettings( QObject* parent ) { qDebug() << "Config version outdated, old:" << value( "configversion" ).toUInt() << "new:" << TOMAHAWK_SETTINGS_VERSION - << "Doing upgrade, if any..."; + << "Doing upgrade, if any, and backing up"; +// QString newname = QString( "%1.v%2" ).arg( dbname ).arg( version ); + if ( format() == IniFormat || + ( format() == NativeFormat +#ifdef Q_OS_WIN + && false +#endif + ) ) + { + qDebug() << "Backing up old ini-style config file"; + const QString path = fileName(); + const QString newname = path + QString( ".v%1" ).arg( value( "configversion" ).toString() ); + QFile::copy( path, newname ); + + } int current = value( "configversion" ).toUInt(); while ( current < TOMAHAWK_SETTINGS_VERSION ) {