mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
More updates for file-mtime scanning
This commit is contained in:
@@ -33,14 +33,19 @@ DatabaseCommand_FileMtimes::exec( DatabaseImpl* dbi )
|
|||||||
void
|
void
|
||||||
DatabaseCommand_FileMtimes::execSelect( DatabaseImpl* dbi )
|
DatabaseCommand_FileMtimes::execSelect( DatabaseImpl* dbi )
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
//FIXME: If ever needed for a non-local source this will have to be fixed/updated
|
//FIXME: If ever needed for a non-local source this will have to be fixed/updated
|
||||||
QMap<QString,unsigned int> mtimes;
|
QMap< QString, QMap< unsigned int, unsigned int > > mtimes;
|
||||||
TomahawkSqlQuery query = dbi->newquery();
|
TomahawkSqlQuery query = dbi->newquery();
|
||||||
if( m_prefix.isEmpty() && m_prefixes.isEmpty() )
|
if( m_prefix.isEmpty() && m_prefixes.isEmpty() )
|
||||||
{
|
{
|
||||||
query.exec( "SELECT id, mtime FROM file WHERE souce IS NULL" );
|
query.exec( "SELECT url, id, mtime FROM file WHERE source IS NULL" );
|
||||||
while( query.next() )
|
while( query.next() )
|
||||||
mtimes.insert( query.value( 0 ).toString(), query.value( 1 ).toUInt() );
|
{
|
||||||
|
QMap< unsigned int, unsigned int > map;
|
||||||
|
map.insert( query.value( 1 ).toUInt(), query.value( 2 ).toUInt() );
|
||||||
|
mtimes.insert( query.value( 0 ).toString(), map );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( m_prefixes.isEmpty() )
|
else if( m_prefixes.isEmpty() )
|
||||||
execSelectPath( dbi, m_prefix, mtimes );
|
execSelectPath( dbi, m_prefix, mtimes );
|
||||||
@@ -55,10 +60,10 @@ DatabaseCommand_FileMtimes::execSelect( DatabaseImpl* dbi )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_FileMtimes::execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap<QString, unsigned int> &mtimes )
|
DatabaseCommand_FileMtimes::execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap<QString, QMap< unsigned int, unsigned int > > &mtimes )
|
||||||
{
|
{
|
||||||
TomahawkSqlQuery query = dbi->newquery();
|
TomahawkSqlQuery query = dbi->newquery();
|
||||||
query.prepare( QString( "SELECT id, mtime "
|
query.prepare( QString( "SELECT url, id, mtime "
|
||||||
"FROM file "
|
"FROM file "
|
||||||
"WHERE source IS NULL "
|
"WHERE source IS NULL "
|
||||||
"AND url LIKE :prefix" ) );
|
"AND url LIKE :prefix" ) );
|
||||||
@@ -67,5 +72,9 @@ DatabaseCommand_FileMtimes::execSelectPath( DatabaseImpl *dbi, const QDir& path,
|
|||||||
query.exec();
|
query.exec();
|
||||||
|
|
||||||
while( query.next() )
|
while( query.next() )
|
||||||
mtimes.insert( query.value( 0 ).toString(), query.value( 1 ).toUInt() );
|
{
|
||||||
|
QMap< unsigned int, unsigned int > map;
|
||||||
|
map.insert( query.value( 1 ).toUInt(), query.value( 2 ).toUInt() );
|
||||||
|
mtimes.insert( query.value( 0 ).toString(), map );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,18 +47,15 @@ public:
|
|||||||
virtual QString commandname() const { return "filemtimes"; }
|
virtual QString commandname() const { return "filemtimes"; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done( const QMap<QString, unsigned int>& );
|
void done( const QMap< QString, QMap< unsigned int, unsigned int > >& );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap<QString, unsigned int> &mtimes );
|
void execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap< QString, QMap< unsigned int, unsigned int > > &mtimes );
|
||||||
|
|
||||||
void execSelect( DatabaseImpl* dbi );
|
void execSelect( DatabaseImpl* dbi );
|
||||||
void execUpdate( DatabaseImpl* dbi );
|
|
||||||
QString m_prefix;
|
QString m_prefix;
|
||||||
QStringList m_prefixes;
|
QStringList m_prefixes;
|
||||||
QMap<QString, unsigned int> m_tosave;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATABASECOMMAND_FILEMTIMES_H
|
#endif // DATABASECOMMAND_FILEMTIMES_H
|
||||||
|
@@ -192,8 +192,8 @@ MusicScanner::setDirMtimes( const QMap<QString, unsigned int>& m )
|
|||||||
if ( m_mode == TomahawkSettings::Files )
|
if ( m_mode == TomahawkSettings::Files )
|
||||||
{
|
{
|
||||||
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes();
|
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes();
|
||||||
connect( cmd, SIGNAL( done( QMap<QString, unsigned int> ) ),
|
connect( cmd, SIGNAL( done( QMap<QString, QMap< unsigned int, unsigned int > > ) ),
|
||||||
SLOT( setFileMtimes( QMap<QString, unsigned int> ) ) );
|
SLOT( setFileMtimes( QMap<QString, QMap< unsigned int, unsigned int > > ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +203,7 @@ MusicScanner::setDirMtimes( const QMap<QString, unsigned int>& m )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MusicScanner::setFileMtimes( const QMap<QString, unsigned int>& m )
|
MusicScanner::setFileMtimes( const QMap<QString, QMap< unsigned int, unsigned int > >& m )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << m.count();
|
qDebug() << Q_FUNC_INFO << m.count();
|
||||||
m_filemtimes = m;
|
m_filemtimes = m;
|
||||||
@@ -324,6 +324,24 @@ MusicScanner::commitBatch( const QVariantList& tracks )
|
|||||||
void
|
void
|
||||||
MusicScanner::scanFile( const QFileInfo& fi )
|
MusicScanner::scanFile( const QFileInfo& fi )
|
||||||
{
|
{
|
||||||
|
//qDebug() << "Scanning file with canonical file path " << fi.canonicalFilePath();
|
||||||
|
//qDebug() << "is directory ? " << ( fi.isDir() ? " yes" : " no");
|
||||||
|
if ( m_mode == TomahawkSettings::Files && m_filemtimes.contains( "file://" + fi.canonicalFilePath() ) )
|
||||||
|
{
|
||||||
|
//qDebug() << "All keys: " << m_filemtimes.keys();
|
||||||
|
//qDebug() << "Checking " << fi.canonicalFilePath() << " with last modified time " << fi.lastModified().toUTC().toTime_t() << " << against value in m_filemtimes " << m_filemtimes.value( "file://" + fi.canonicalFilePath() ).values().first();
|
||||||
|
if ( fi.lastModified().toUTC().toTime_t() == m_filemtimes.value( "file://" + fi.canonicalFilePath() ).values().first() )
|
||||||
|
{
|
||||||
|
qDebug() << "Same mtime";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Different mtime";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant m = readFile( fi );
|
QVariant m = readFile( fi );
|
||||||
if ( m.toMap().isEmpty() )
|
if ( m.toMap().isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
@@ -100,8 +100,8 @@ private slots:
|
|||||||
void scanFile( const QFileInfo& fi );
|
void scanFile( const QFileInfo& fi );
|
||||||
void startScan();
|
void startScan();
|
||||||
void scan();
|
void scan();
|
||||||
void setDirMtimes( const QMap<QString, unsigned int>& m );
|
void setDirMtimes( const QMap< QString, unsigned int >& m );
|
||||||
void setFileMtimes( const QMap<QString, unsigned int>& m );
|
void setFileMtimes( const QMap< QString, QMap< unsigned int, unsigned int > >& m );
|
||||||
void commitBatch( const QVariantList& );
|
void commitBatch( const QVariantList& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -114,7 +114,7 @@ private:
|
|||||||
QList<QString> m_skippedFiles;
|
QList<QString> m_skippedFiles;
|
||||||
|
|
||||||
QMap<QString, unsigned int> m_dirmtimes;
|
QMap<QString, unsigned int> m_dirmtimes;
|
||||||
QMap<QString, unsigned int> m_filemtimes;
|
QMap<QString, QMap< unsigned int, unsigned int > > m_filemtimes;
|
||||||
QMap<QString, unsigned int> m_newdirmtimes;
|
QMap<QString, unsigned int> m_newdirmtimes;
|
||||||
|
|
||||||
QList<QVariant> m_scannedfiles;
|
QList<QVariant> m_scannedfiles;
|
||||||
|
@@ -56,7 +56,8 @@ ScanManager::ScanManager( QObject* parent )
|
|||||||
connect( m_scanTimer, SIGNAL( timeout() ), SLOT( scanTimerTimeout() ) );
|
connect( m_scanTimer, SIGNAL( timeout() ), SLOT( scanTimerTimeout() ) );
|
||||||
|
|
||||||
// FIXME: Disable this until we find something nondeprecated and working (e.g. not QFileSystemWatcher)
|
// FIXME: Disable this until we find something nondeprecated and working (e.g. not QFileSystemWatcher)
|
||||||
//TomahawkSettings::instance()->setWatchForChanges( true );
|
TomahawkSettings::instance()->setWatchForChanges( true );
|
||||||
|
TomahawkSettings::instance()->setScannerMode( TomahawkSettings::Files );
|
||||||
|
|
||||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||||
{
|
{
|
||||||
|
@@ -368,6 +368,7 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
||||||
qRegisterMetaType< QMap< QString, plentry_ptr > >("QMap< QString, plentry_ptr >");
|
qRegisterMetaType< QMap< QString, plentry_ptr > >("QMap< QString, plentry_ptr >");
|
||||||
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
||||||
|
qRegisterMetaType< QMap< QString, QMap< unsigned int, unsigned int > > >("QMap< QString, QMap< unsigned int, unsigned int > >");
|
||||||
|
|
||||||
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
||||||
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
||||||
|
Reference in New Issue
Block a user