mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 04:10:20 +02:00
Properly handle order in which mtime update and file delete commands are
run in relation to the rest of scanning
This commit is contained in:
@@ -89,4 +89,5 @@ DatabaseCommand_DirMtimes::execUpdate( DatabaseImpl* dbi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Saved mtimes for" << m_tosave.size() << "dirs.";
|
qDebug() << "Saved mtimes for" << m_tosave.size() << "dirs.";
|
||||||
|
emit done( QMap< QString, unsigned int >() );
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ DirLister::go()
|
|||||||
{
|
{
|
||||||
if ( m_dirmtimes.contains( dir ) )
|
if ( m_dirmtimes.contains( dir ) )
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << "Removing" << dir << "from m_dirmtimes because it's specifically requested";
|
tDebug( LOGEXTRA ) << "Removing" << dir << "from m_dirmtimes because it's specifically requested (so we want to be sure to scan it)";
|
||||||
m_dirmtimes.remove( dir );
|
m_dirmtimes.remove( dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ DirLister::go()
|
|||||||
m_newdirmtimes = m_dirmtimes;
|
m_newdirmtimes = m_dirmtimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tDebug( LOGEXTRA ) << "m_dirmtimes = " << m_dirmtimes;
|
||||||
foreach ( const QString& dir, m_dirs )
|
foreach ( const QString& dir, m_dirs )
|
||||||
{
|
{
|
||||||
m_opcount++;
|
m_opcount++;
|
||||||
@@ -101,10 +102,11 @@ DirLister::scanDir( QDir dir, int depth, DirLister::Mode mode )
|
|||||||
|
|
||||||
if ( 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.
|
tDebug( LOGVERBOSE ) << "Dir unchanged";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Dir changed";
|
||||||
if ( m_mode == TomahawkSettings::Dirs
|
if ( m_mode == TomahawkSettings::Dirs
|
||||||
&& ( m_dirmtimes.contains( dir.canonicalPath() ) || !m_recursive )
|
&& ( m_dirmtimes.contains( dir.canonicalPath() ) || !m_recursive )
|
||||||
&& mtime != m_dirmtimes.value( dir.canonicalPath() ) )
|
&& mtime != m_dirmtimes.value( dir.canonicalPath() ) )
|
||||||
@@ -207,7 +209,8 @@ MusicScanner::setDirMtimes( const QMap< QString, unsigned int >& m )
|
|||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scan();
|
else
|
||||||
|
scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -136,7 +136,39 @@ ScanManager::runScan( bool manualFull )
|
|||||||
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
runDirScan( TomahawkSettings::instance()->scannerPaths(), manualFull );
|
if ( !manualFull )
|
||||||
|
{
|
||||||
|
runDirScan( TomahawkSettings::instance()->scannerPaths(), false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseCommand_DirMtimes *cmd = new DatabaseCommand_DirMtimes( QMap<QString, unsigned int>() );
|
||||||
|
connect( cmd, SIGNAL( done( QMap< QString, unsigned int > ) ),
|
||||||
|
SLOT( mtimesDeleted( QMap< QString, unsigned int > ) ) );
|
||||||
|
|
||||||
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScanManager::mtimesDeleted( QMap< QString, unsigned int > returnedMap )
|
||||||
|
{
|
||||||
|
Q_UNUSED( returnedMap );
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
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 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScanManager::filesDeleted( const QStringList& files, const Tomahawk::collection_ptr& collection )
|
||||||
|
{
|
||||||
|
Q_UNUSED( files );
|
||||||
|
Q_UNUSED( collection );
|
||||||
|
runDirScan( TomahawkSettings::instance()->scannerPaths(), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -148,12 +180,11 @@ ScanManager::runDirScan( const QStringList& paths, bool manualFull )
|
|||||||
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( paths.isEmpty() || manualFull )
|
if ( paths.isEmpty() )
|
||||||
{
|
{
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ) ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() ) ) );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DirMtimes( QMap<QString, unsigned int>() ) ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( new DatabaseCommand_DirMtimes( QMap<QString, unsigned int>() ) ) );
|
||||||
if ( paths.isEmpty() )
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_musicScannerThreadController && m_scanner.isNull() ) //still running if these are not zero
|
if ( !m_musicScannerThreadController && m_scanner.isNull() ) //still running if these are not zero
|
||||||
|
@@ -19,12 +19,13 @@
|
|||||||
#ifndef SCANMANAGER_H
|
#ifndef SCANMANAGER_H
|
||||||
#define SCANMANAGER_H
|
#define SCANMANAGER_H
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
class MusicScanner;
|
class MusicScanner;
|
||||||
@@ -57,6 +58,9 @@ private slots:
|
|||||||
|
|
||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
|
void mtimesDeleted( QMap< QString, unsigned int > returnedMap );
|
||||||
|
void filesDeleted( const QStringList& files, const Tomahawk::collection_ptr& collection );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ScanManager* s_instance;
|
static ScanManager* s_instance;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user