mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
Don't add directories to the watcher if watch for changes is disabled
This commit is contained in:
@@ -67,10 +67,12 @@ ScanManager::ScanManager( QObject* parent )
|
|||||||
connect( m_dirWatcher, SIGNAL( directoryChanged( const QString & ) ), SLOT( handleChangedDir( const QString & ) ) );
|
connect( m_dirWatcher, SIGNAL( directoryChanged( const QString & ) ), SLOT( handleChangedDir( const QString & ) ) );
|
||||||
|
|
||||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||||
|
{
|
||||||
m_currScannerPaths = TomahawkSettings::instance()->scannerPaths();
|
m_currScannerPaths = TomahawkSettings::instance()->scannerPaths();
|
||||||
|
if ( TomahawkSettings::instance()->watchForChanges() )
|
||||||
qDebug() << "loading initial directories to watch";
|
QTimer::singleShot( 1000, this, SLOT( runStartupScan() ) );
|
||||||
QTimer::singleShot( 1000, this, SLOT( startupWatchPaths() ) );
|
}
|
||||||
|
|
||||||
m_deferredScanTimer->start();
|
m_deferredScanTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +111,6 @@ ScanManager::onSettingsChanged()
|
|||||||
{
|
{
|
||||||
m_currScannerPaths = TomahawkSettings::instance()->scannerPaths();
|
m_currScannerPaths = TomahawkSettings::instance()->scannerPaths();
|
||||||
m_dirWatcher->removePaths( m_dirWatcher->directories() );
|
m_dirWatcher->removePaths( m_dirWatcher->directories() );
|
||||||
m_dirWatcher->addPaths( m_currScannerPaths );
|
|
||||||
runManualScan( m_currScannerPaths );
|
runManualScan( m_currScannerPaths );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,35 +120,13 @@ ScanManager::onSettingsChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void ScanManager::runStartupScan()
|
||||||
ScanManager::startupWatchPaths()
|
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
if( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
if( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
{
|
QTimer::singleShot( 1000, this, SLOT( runStartupScan() ) );
|
||||||
QTimer::singleShot( 1000, this, SLOT( startupWatchPaths() ) );
|
else
|
||||||
return;
|
runManualScan( m_currScannerPaths );
|
||||||
}
|
|
||||||
|
|
||||||
DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( m_currScannerPaths );
|
|
||||||
connect( cmd, SIGNAL( done( QMap< QString, unsigned int > ) ),
|
|
||||||
SLOT( setInitialPaths( QMap< QString, unsigned int > ) ) );
|
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScanManager::setInitialPaths( QMap< QString, unsigned int > pathMap )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
foreach( QString path, pathMap.keys() )
|
|
||||||
{
|
|
||||||
qDebug() << "Adding " << path << " to watcher";
|
|
||||||
m_dirWatcher->addPath( path );
|
|
||||||
}
|
|
||||||
if( TomahawkSettings::instance()->hasScannerPaths() && TomahawkSettings::instance()->watchForChanges() )
|
|
||||||
runManualScan( TomahawkSettings::instance()->scannerPaths() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,6 +135,9 @@ ScanManager::runManualScan( const QStringList& paths, bool recursive )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
if( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( !m_musicScannerThreadController && !m_scanner ) //still running if these are not zero
|
if ( !m_musicScannerThreadController && !m_scanner ) //still running if these are not zero
|
||||||
{
|
{
|
||||||
m_musicScannerThreadController = new QThread( this );
|
m_musicScannerThreadController = new QThread( this );
|
||||||
@@ -193,10 +175,13 @@ void
|
|||||||
ScanManager::addWatchedDirs( const QStringList& paths )
|
ScanManager::addWatchedDirs( const QStringList& paths )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
if ( !TomahawkSettings::instance()->watchForChanges() )
|
||||||
|
return;
|
||||||
|
|
||||||
QStringList currentWatchedPaths = m_dirWatcher->directories();
|
QStringList currentWatchedPaths = m_dirWatcher->directories();
|
||||||
foreach( QString path, paths )
|
foreach ( QString path, paths )
|
||||||
{
|
{
|
||||||
if( !currentWatchedPaths.contains( path ) )
|
if ( !currentWatchedPaths.contains( path ) )
|
||||||
{
|
{
|
||||||
qDebug() << "adding " << path << " to watched dirs";
|
qDebug() << "adding " << path << " to watched dirs";
|
||||||
m_dirWatcher->addPath( path );
|
m_dirWatcher->addPath( path );
|
||||||
|
@@ -49,14 +49,13 @@ public slots:
|
|||||||
void handleChangedDir( const QString& path );
|
void handleChangedDir( const QString& path );
|
||||||
void addWatchedDirs( const QStringList& paths );
|
void addWatchedDirs( const QStringList& paths );
|
||||||
void removeWatchedDir( const QString& path );
|
void removeWatchedDir( const QString& path );
|
||||||
void setInitialPaths( QMap< QString, unsigned int > pathMap );
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void scannerQuit();
|
void scannerQuit();
|
||||||
void scannerFinished();
|
void scannerFinished();
|
||||||
void scannerDestroyed( QObject* scanner );
|
void scannerDestroyed( QObject* scanner );
|
||||||
|
|
||||||
void startupWatchPaths();
|
void runStartupScan();
|
||||||
void queuedScanTimeout();
|
void queuedScanTimeout();
|
||||||
void deferredScanTimeout();
|
void deferredScanTimeout();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user