mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 09:19:41 +01:00
account dedup
This commit is contained in:
parent
1360d28b25
commit
ddd0af895f
@ -408,6 +408,42 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
||||
setValue( "allaccounts", allAccounts );
|
||||
endGroup();
|
||||
}
|
||||
else if ( oldVersion == 8 )
|
||||
{
|
||||
// Some users got duplicate accounts for some reason, so make them unique if we can
|
||||
QSet< QString > uniqueFriendlyNames;
|
||||
beginGroup("accounts");
|
||||
const QStringList accounts = childGroups();
|
||||
QStringList allAccounts = value( "allaccounts" ).toStringList();
|
||||
|
||||
// qDebug() << "Got accounts to migrate:" << accounts;
|
||||
foreach ( const QString& account, accounts )
|
||||
{
|
||||
if ( !allAccounts.contains( account ) ) // orphan
|
||||
{
|
||||
qDebug() << "Found account not in allaccounts list!" << account << "is a dup!";
|
||||
remove( account );
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString friendlyName = value( QString( "%1/accountfriendlyname" ).arg( account ) ).toString();
|
||||
if ( !uniqueFriendlyNames.contains( friendlyName ) )
|
||||
{
|
||||
uniqueFriendlyNames.insert( friendlyName );
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Duplicate..?
|
||||
qDebug() << "Found duplicate account friendly name:" << account << friendlyName << "is a dup!";
|
||||
remove( account );
|
||||
allAccounts.removeAll( account );
|
||||
}
|
||||
}
|
||||
qDebug() << "Ended up with all accounts list:" << allAccounts << "and all accounts:" << childGroups();
|
||||
setValue( "allaccounts", allAccounts );
|
||||
endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#define TOMAHAWK_SETTINGS_VERSION 8
|
||||
#define TOMAHAWK_SETTINGS_VERSION 9
|
||||
|
||||
/**
|
||||
* Convenience wrapper around QSettings for tomahawk-specific config
|
||||
|
Loading…
x
Reference in New Issue
Block a user