mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 01:54:07 +02:00
Remove bundle directory on account removal.
This commit is contained in:
@@ -351,6 +351,10 @@ AccountManager::removeAccount( Account* account )
|
||||
m_accountsByAccountType[ type ] = accounts;
|
||||
}
|
||||
|
||||
ResolverAccount* raccount = qobject_cast< ResolverAccount* >( account );
|
||||
if ( raccount )
|
||||
raccount->removeBundle();
|
||||
|
||||
TomahawkSettings::instance()->removeAccount( account->accountId() );
|
||||
|
||||
account->removeFromConfig();
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
#define MANUALRESOLVERS_DIR "manualresolvers"
|
||||
|
||||
using namespace Tomahawk;
|
||||
using namespace Accounts;
|
||||
|
||||
@@ -85,9 +87,10 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
|
||||
|
||||
if ( pathInfo.suffix() == "axe" )
|
||||
{
|
||||
QString uniqueName = uuid();
|
||||
QDir dir( TomahawkUtils::extractScriptPayload( pathInfo.filePath(),
|
||||
pathInfo.completeBaseName(),
|
||||
"manualresolvers" ) );
|
||||
uniqueName,
|
||||
MANUALRESOLVERS_DIR ) );
|
||||
if ( !( dir.exists() && dir.isReadable() ) ) //decompression fubar
|
||||
return 0;
|
||||
|
||||
@@ -95,9 +98,10 @@ ResolverAccountFactory::createFromPath( const QString& path, const QString& fact
|
||||
return 0;
|
||||
|
||||
QString metadataFilePath = dir.absoluteFilePath( "metadata.json" );
|
||||
|
||||
configuration = metadataFromJsonFile( metadataFilePath );
|
||||
|
||||
realPath = configuration[ "path" ].toString();
|
||||
configuration[ "bundleDir" ] = uniqueName;
|
||||
if ( realPath.isEmpty() )
|
||||
return 0;
|
||||
}
|
||||
@@ -133,6 +137,7 @@ ResolverAccountFactory::metadataFromJsonFile( const QString& path )
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
result[ "pluginName" ] = variant[ "pluginName" ];
|
||||
result[ "author" ] = variant[ "author" ];
|
||||
result[ "description" ] = variant[ "description" ];
|
||||
if ( !variant[ "manifest" ].isNull() )
|
||||
@@ -371,6 +376,22 @@ ResolverAccount::version() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResolverAccount::removeBundle()
|
||||
{
|
||||
QString bundleDir = configuration()[ "bundleDir" ].toString();
|
||||
if ( bundleDir.isEmpty() )
|
||||
return;
|
||||
|
||||
QString expectedPath = TomahawkUtils::appDataDir().absoluteFilePath( QString( "%1/%2" ).arg( MANUALRESOLVERS_DIR ).arg( bundleDir ) );
|
||||
QFileInfo fi( expectedPath );
|
||||
if ( fi.exists() && fi.isDir() && fi.isWritable() )
|
||||
{
|
||||
TomahawkUtils::removeDirectory( expectedPath );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// AtticaResolverAccount
|
||||
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId )
|
||||
|
@@ -93,6 +93,8 @@ public:
|
||||
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
|
||||
virtual QWidget* aclWidget() { return 0; }
|
||||
|
||||
virtual void removeBundle();
|
||||
|
||||
private slots:
|
||||
void resolverChanged();
|
||||
|
||||
|
Reference in New Issue
Block a user