From kde-commits Sat Jun 02 07:46:23 2007 From: Mark Kretschmann Date: Sat, 02 Jun 2007 07:46:23 +0000 To: kde-commits Subject: branches/stable/extragear/multimedia/amarok Message-Id: <1180770383.349255.22624.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=118077039432499 SVN commit 670627 by markey: Always uninstall scripts correctly. Thanks Sergio! BUG: 143716 M +2 -0 ChangeLog M +22 -7 src/scriptmanager.cpp --- branches/stable/extragear/multimedia/amarok/ChangeLog #670626:670627 @@ -30,6 +30,8 @@ and one full star. BUGFIXES: + * Uninstalling scripts would in some cases leave files behind. Patch by + Sergio Pistone . (BR 143716) * Last.fm "Custom Station" stream works again. (BR 146020) * Fix regression where the "Show Script Manager" button displayed on the Lyrics tab of the Context Browser wouldn't actually show the Script --- branches/stable/extragear/multimedia/amarok/src/scriptmanager.cpp #670626:670627 @@ -518,21 +518,36 @@ if( m_scripts.find( name ) == m_scripts.end() ) return; - const QString directory = m_scripts[name].url.directory(); + KURL scriptDirURL( m_scripts[name].url.upURL() ); - // Delete directory recursively - const KURL url = KURL::fromPathOrURL( directory ); - if( !KIO::NetAccess::del( url, 0 ) ) { - KMessageBox::sorry( 0, i18n( "

Could not uninstall this script.

The ScriptManager can only uninstall scripts which have been installed as packages.

" ) ); + // find if the script is installed in the global or local scripts directory + KURL scriptsDirURL; + QStringList dirs = KGlobal::dirs()->findDirs( "data", "amarok/scripts/" ); + for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); ++it ) { + scriptsDirURL = KURL::fromPathOrURL( *it ); + if ( scriptsDirURL.isParentOf( scriptDirURL ) ) + break; + } + + // find the begining of this script directory tree + KURL scriptDirUpURL = scriptDirURL.upURL(); + while ( ! scriptsDirURL.equals( scriptDirUpURL, true ) && scriptsDirURL.isParentOf( scriptDirUpURL ) ) { + scriptDirURL = scriptDirUpURL; + scriptDirUpURL = scriptDirURL.upURL(); + } + + // Delete script directory recursively + if( !KIO::NetAccess::del( scriptDirURL, 0 ) ) { + KMessageBox::sorry( 0, i18n( "

Could not uninstall this script.

The ScriptManager can only uninstall scripts which have been installed as packages.

" ) ); // only true when not running as root (which is reasonable) return; } QStringList keys; - // Find all scripts that were in the uninstalled folder + // Find all scripts that were in the uninstalled directory { foreachType( ScriptMap, m_scripts ) - if( it.data().url.directory() == directory ) + if( scriptDirURL.isParentOf( it.data().url ) ) keys << it.key(); }