From 1a9bf84ab4668c8f7020a7aabf3c95e7ac169bd2 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 29 Jun 2012 17:05:51 -0400 Subject: [PATCH] Don't copy to bundle any longer when installing binary resolvers on osx --- src/libtomahawk/utils/BinaryExtractWorker.cpp | 74 +++++-------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/src/libtomahawk/utils/BinaryExtractWorker.cpp b/src/libtomahawk/utils/BinaryExtractWorker.cpp index 0c4353676..624d452fa 100644 --- a/src/libtomahawk/utils/BinaryExtractWorker.cpp +++ b/src/libtomahawk/utils/BinaryExtractWorker.cpp @@ -35,71 +35,37 @@ namespace TomahawkUtils void BinaryExtractWorker::run() { - ScopedDeleter deleter( this ); - -#ifdef Q_OS_MAC - // Platform-specific handling of resolver payload now. We know it's good - // Unzip the file. - QFileInfo info( m_zipFileName ); - QDir tmpDir = QDir::tempPath(); - if ( !tmpDir.mkdir( info.baseName() ) ) - { - qWarning() << "Failed to create temporary directory to unzip in:" << tmpDir.absolutePath(); - return; - } - tmpDir.cd( info.baseName() ); - TomahawkUtils::unzipFileInFolder( info.absoluteFilePath(), tmpDir ); - - // On OSX it just contains 1 file, the resolver executable itself. For now. We just copy it to - // the Tomahawk.app/Contents/MacOS/ folder alongside the Tomahawk executable. - const QString dest = QCoreApplication::applicationDirPath(); - // Find the filename - const QDir toList( tmpDir.absolutePath() ); - const QStringList files = toList.entryList( QStringList(), QDir::Files ); - Q_ASSERT( files.size() == 1 ); - - const QString src = toList.absoluteFilePath( files.first() ); - qDebug() << "OS X: Copying binary resolver from to:" << src << dest; - - copyWithAuthentication( src, dest, m_receiver ); - + ScopedDeleter deleter( this ); + // We unzip directly to the target location, just like normal attica resolvers + Q_ASSERT( m_receiver ); + if ( !m_receiver ) return; -#elif defined(Q_OS_WIN) || defined(Q_OS_LINUX) - // We unzip directly to the target location, just like normal attica resolvers - Q_ASSERT( m_receiver ); - if ( !m_receiver ) - return; - const QString resolverId = m_receiver->property( "resolverid" ).toString(); + const QString resolverId = m_receiver->property( "resolverid" ).toString(); - Q_ASSERT( !resolverId.isEmpty() ); - if ( resolverId.isEmpty() ) - return; + Q_ASSERT( !resolverId.isEmpty() ); + if ( resolverId.isEmpty() ) + return; - const QDir resolverPath( extractScriptPayload( m_zipFileName, resolverId ) ); + const QDir resolverPath( extractScriptPayload( m_zipFileName, resolverId ) ); #ifdef Q_OS_WIN - const QStringList files = resolverPath.entryList( QStringList() << "*.exe", QDir::Files ); -#elif defined(Q_OS_LINUX) - const QStringList files = resolverPath.entryList( QStringList() << "*_tomahawkresolver", QDir::Files ); + const QStringList files = resolverPath.entryList( QStringList() << "*.exe", QDir::Files ); +#else + const QStringList files = resolverPath.entryList( QStringList() << "*_tomahawkresolver", QDir::Files ); #endif - qDebug() << "Found executables in unzipped binary resolver dir:" << files; - Q_ASSERT( files.size() == 1 ); - if ( files.size() < 1 ) - return; + qDebug() << "Found executables in unzipped binary resolver dir:" << files; + Q_ASSERT( files.size() == 1 ); + if ( files.size() < 1 ) + return; - const QString resolverToUse = resolverPath.absoluteFilePath( files.first() ); + const QString resolverToUse = resolverPath.absoluteFilePath( files.first() ); -#ifdef Q_OS_LINUX - QProcess p; - p.start( "chmod", QStringList() << "744" << resolverToUse, QIODevice::ReadOnly ); - p.waitForFinished(); -#endif + QFile file( resolverToUse ); + file.setPermissions( file.permissions() | QFile::ExeOwner | QFile::ExeGroup | QFile::ExeOther ); - QMetaObject::invokeMethod( m_receiver, "installSucceeded", Qt::QueuedConnection, Q_ARG( QString, resolverToUse ) ); - -#endif + QMetaObject::invokeMethod( m_receiver, "installSucceeded", Qt::QueuedConnection, Q_ARG( QString, resolverToUse ) ); } }