From 011ece182f3257c02e46e41144dfe00d09ed8a18 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 11 Nov 2011 19:46:44 +0100 Subject: [PATCH] * Prevent watch for changes interfering with running scan. --- src/scanmanager.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/scanmanager.cpp b/src/scanmanager.cpp index f54e27dd8..0b633c7ad 100644 --- a/src/scanmanager.cpp +++ b/src/scanmanager.cpp @@ -135,22 +135,29 @@ ScanManager::runScan( bool manualFull ) if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) ) return; - if ( manualFull ) + if ( !m_musicScannerThreadController && m_scanner.isNull() ) //still running if these are not zero { - DatabaseCommand_DeleteFiles *cmd = new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ); - connect( cmd, SIGNAL( done( const QStringList&, const Tomahawk::collection_ptr& ) ), - SLOT( filesDeleted( const QStringList&, const Tomahawk::collection_ptr& ) ) ); + if ( manualFull ) + { + DatabaseCommand_DeleteFiles *cmd = new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ); + connect( cmd, SIGNAL( done( const QStringList&, const Tomahawk::collection_ptr& ) ), + SLOT( filesDeleted( const QStringList&, const Tomahawk::collection_ptr& ) ) ); + + Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); + return; + } + + DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true ); + connect( cmd, SIGNAL( done( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ), + SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) ); Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); + } + else + { + qDebug() << "Could not run dir scan, old scan still running"; return; } - - DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true ); - connect( cmd, SIGNAL( done( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ), - SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) ); - - Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); - } @@ -166,7 +173,7 @@ ScanManager::fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); return; } - + runDirScan(); } @@ -190,7 +197,7 @@ ScanManager::runDirScan() return; QStringList paths = TomahawkSettings::instance()->scannerPaths(); - + if ( !m_musicScannerThreadController && m_scanner.isNull() ) //still running if these are not zero { m_scanTimer->stop();