mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Remove confusing manualFull variable that got passed all the way into
scanners, use faster delete command when doing a full rescan
This commit is contained in:
parent
ff764df4af
commit
e47b750d21
@ -39,7 +39,6 @@ void
|
||||
DirLister::go()
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Recursive? :" << (m_recursive ? "true" : "false");
|
||||
tLog() << Q_FUNC_INFO << "Manual full? :" << (m_manualFull ? "true" : "false");
|
||||
|
||||
if ( !m_recursive )
|
||||
{
|
||||
@ -100,16 +99,15 @@ DirLister::scanDir( QDir dir, int depth, DirLister::Mode mode )
|
||||
const uint mtime = QFileInfo( dir.canonicalPath() ).lastModified().toUTC().toTime_t();
|
||||
m_newdirmtimes.insert( dir.canonicalPath(), mtime );
|
||||
|
||||
if ( !m_manualFull && m_mode == TomahawkSettings::Dirs && m_dirmtimes.contains( dir.canonicalPath() ) && mtime == m_dirmtimes.value( dir.canonicalPath() ) )
|
||||
if ( m_mode == TomahawkSettings::Dirs && m_dirmtimes.contains( dir.canonicalPath() ) && mtime == m_dirmtimes.value( dir.canonicalPath() ) )
|
||||
{
|
||||
// dont scan this dir, unchanged since last time.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_manualFull ||
|
||||
( m_mode == TomahawkSettings::Dirs
|
||||
if ( m_mode == TomahawkSettings::Dirs
|
||||
&& ( m_dirmtimes.contains( dir.canonicalPath() ) || !m_recursive )
|
||||
&& mtime != m_dirmtimes.value( dir.canonicalPath() ) ) )
|
||||
&& mtime != m_dirmtimes.value( dir.canonicalPath() ) )
|
||||
{
|
||||
tDebug( LOGINFO ) << "Deleting database file entries from" << dir.canonicalPath();
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( new DatabaseCommand_DeleteFiles( dir, SourceList::instance()->getLocal() ) ) );
|
||||
@ -141,11 +139,10 @@ DirLister::scanDir( QDir dir, int depth, DirLister::Mode mode )
|
||||
}
|
||||
|
||||
|
||||
MusicScanner::MusicScanner( const QStringList& dirs, TomahawkSettings::ScannerMode mode, bool manualFull, bool recursive, quint32 bs )
|
||||
MusicScanner::MusicScanner( const QStringList& dirs, TomahawkSettings::ScannerMode mode, bool recursive, quint32 bs )
|
||||
: QObject()
|
||||
, m_dirs( dirs )
|
||||
, m_mode( manualFull ? TomahawkSettings::Dirs : mode )
|
||||
, m_manualFull( manualFull )
|
||||
, m_mode( mode )
|
||||
, m_recursive( recursive )
|
||||
, m_batchsize( bs )
|
||||
, m_dirListerThreadController( 0 )
|
||||
@ -235,7 +232,7 @@ MusicScanner::scan()
|
||||
|
||||
m_dirListerThreadController = new QThread( this );
|
||||
|
||||
m_dirLister = QWeakPointer< DirLister >( new DirLister( m_dirs, m_dirmtimes, m_mode, m_manualFull, m_recursive ) );
|
||||
m_dirLister = QWeakPointer< DirLister >( new DirLister( m_dirs, m_dirmtimes, m_mode, m_recursive ) );
|
||||
m_dirLister.data()->moveToThread( m_dirListerThreadController );
|
||||
|
||||
connect( m_dirLister.data(), SIGNAL( fileToScan( QFileInfo ) ),
|
||||
|
@ -50,8 +50,8 @@ public:
|
||||
MTimeOnly
|
||||
};
|
||||
|
||||
DirLister( const QStringList& dirs, const QMap<QString, unsigned int>& dirmtimes, TomahawkSettings::ScannerMode mode, bool manualFull, bool recursive )
|
||||
: QObject(), m_dirs( dirs ), m_dirmtimes( dirmtimes ), m_mode( mode ), m_manualFull( manualFull ), m_recursive( recursive ), m_opcount( 0 ), m_deleting( false )
|
||||
DirLister( const QStringList& dirs, const QMap<QString, unsigned int>& dirmtimes, TomahawkSettings::ScannerMode mode, bool recursive )
|
||||
: QObject(), m_dirs( dirs ), m_dirmtimes( dirmtimes ), m_mode( mode ), m_recursive( recursive ), m_opcount( 0 ), m_deleting( false )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
@ -76,7 +76,6 @@ private:
|
||||
QStringList m_dirs;
|
||||
QMap<QString, unsigned int> m_dirmtimes;
|
||||
TomahawkSettings::ScannerMode m_mode;
|
||||
bool m_manualFull;
|
||||
bool m_recursive;
|
||||
|
||||
QMap<QString, unsigned int> m_newdirmtimes;
|
||||
@ -92,7 +91,7 @@ class MusicScanner : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MusicScanner( const QStringList& dirs, TomahawkSettings::ScannerMode mode, bool manualFull, bool recursive = true, quint32 bs = 0 );
|
||||
MusicScanner( const QStringList& dirs, TomahawkSettings::ScannerMode mode, bool recursive = true, quint32 bs = 0 );
|
||||
~MusicScanner();
|
||||
|
||||
signals:
|
||||
@ -127,7 +126,6 @@ private:
|
||||
|
||||
QVariantList m_scannedfiles;
|
||||
QVariantList m_filesToDelete;
|
||||
bool m_manualFull;
|
||||
bool m_recursive;
|
||||
quint32 m_batchsize;
|
||||
|
||||
|
@ -148,17 +148,19 @@ ScanManager::runDirScan( const QStringList& paths, bool manualFull )
|
||||
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||
return;
|
||||
|
||||
if ( paths.isEmpty() )
|
||||
if ( paths.isEmpty() || manualFull )
|
||||
{
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ) ) );
|
||||
return;
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ) ) );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DirMtimes( QMap<QString, unsigned int>() ) ) );
|
||||
if ( paths.isEmpty() )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !m_musicScannerThreadController && m_scanner.isNull() ) //still running if these are not zero
|
||||
{
|
||||
m_scanTimer->stop();
|
||||
m_musicScannerThreadController = new QThread( this );
|
||||
m_scanner = QWeakPointer< MusicScanner>( new MusicScanner( paths, TomahawkSettings::instance()->scannerMode(), manualFull ) );
|
||||
m_scanner = QWeakPointer< MusicScanner>( new MusicScanner( paths, manualFull ? TomahawkSettings::Dirs : TomahawkSettings::instance()->scannerMode() ) );
|
||||
m_scanner.data()->moveToThread( m_musicScannerThreadController );
|
||||
connect( m_scanner.data(), SIGNAL( finished() ), SLOT( scannerFinished() ) );
|
||||
m_musicScannerThreadController->start( QThread::IdlePriority );
|
||||
|
Loading…
x
Reference in New Issue
Block a user