~hile/mixxx/hidscripts

« back to all changes in this revision

Viewing changes to mixxx/src/library/libraryscanner.cpp

  • Committer: Ilkka Tuohela
  • Date: 2012-07-30 05:40:10 UTC
  • mfrom: (3162.1.128 trunk)
  • Revision ID: hile@iki.fi-20120730054010-qf2pmfpp9zj4meh3
MergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    m_trackDao(m_database, m_cueDao, m_playlistDao, m_crateDao, m_analysisDao),
38
38
    // Don't initialize m_database here, we need to do it in run() so the DB
39
39
    // conn is in the right thread.
40
 
    m_nameFilters(SoundSourceProxy::supportedFileExtensionsString().split(" "))
 
40
    m_nameFilters(SoundSourceProxy::supportedFileExtensionsString().split(" ")),
 
41
    m_bCancelLibraryScan(0)
41
42
{
42
43
 
43
44
    qDebug() << "Constructed LibraryScanner";
44
 
    resetCancel();
45
45
 
46
46
    // Force the GUI thread's TrackInfoObject cache to be cleared when a library
47
47
    // scan is finished, because we might have modified the database directly
80
80
 
81
81
    if (isRunning()) {
82
82
        // Cancel any running library scan...
83
 
        m_pCollection->slotCancelLibraryScan();
84
 
        this->cancel();
85
 
 
 
83
        cancel();
86
84
        wait(); // Wait for thread to finish
87
85
    }
88
86
 
174
172
    m_playlistDao.initialize();
175
173
    m_analysisDao.initialize();
176
174
 
177
 
    m_pCollection->resetLibaryCancellation();
 
175
    resetCancel();
178
176
 
179
177
    QTime t2;
180
178
    t2.start();
236
234
    // Runs inside a transaction
237
235
    m_trackDao.addTracksFinish();
238
236
 
 
237
    //Verify all Tracks inside Library but outside the library path
 
238
    m_trackDao.verifyTracksOutside(m_qLibraryPath, &m_bCancelLibraryScan);
 
239
 
239
240
    // Start a transaction for all the library hashing (moved file detection)
240
241
    // stuff.
241
242
    ScopedTransaction transaction(m_database);
284
285
    // Update BaseTrackCache via the main TrackDao
285
286
    m_pCollection->getTrackDAO().databaseTracksMoved(tracksMovedSetOld, tracksMovedSetNew);
286
287
 
287
 
    resetCancel();
288
288
    emit(scanFinished());
289
289
}
290
290
 
310
310
    connect(this, SIGNAL(scanFinished()),
311
311
            m_pProgress, SLOT(slotScanFinished()));
312
312
    connect(m_pProgress, SIGNAL(scanCancelled()),
313
 
            m_pCollection, SLOT(slotCancelLibraryScan()));
314
 
    connect(m_pProgress, SIGNAL(scanCancelled()),
315
313
            this, SLOT(cancel()));
 
314
    connect(&m_trackDao, SIGNAL(progressVerifyTracksOutside(QString)),
 
315
            m_pProgress, SLOT(slotUpdate(QString)));
316
316
    scan();
317
317
}
318
318
 
 
319
//slot
319
320
void LibraryScanner::cancel()
320
321
{
321
 
    m_libraryScanMutex.lock();
322
322
    m_bCancelLibraryScan = 1;
323
 
    m_libraryScanMutex.unlock();
324
323
}
325
324
 
326
325
void LibraryScanner::resetCancel()
327
326
{
328
 
    m_libraryScanMutex.lock();
329
327
    m_bCancelLibraryScan = 0;
330
 
    m_libraryScanMutex.unlock();
331
328
}
332
329
 
333
330
void LibraryScanner::scan()
378
375
        }
379
376
 
380
377
        // Rescan that mofo!
381
 
        bScanFinishedCleanly = m_pCollection->importDirectory(dirPath, m_trackDao, m_nameFilters);
 
378
        bScanFinishedCleanly = m_pCollection->importDirectory(dirPath, m_trackDao, m_nameFilters, &m_bCancelLibraryScan);
382
379
    } else { //prevHash == newHash
383
380
        // Add the directory to the verifiedDirectories list, so that later they
384
381
        // (and the tracks inside them) will be marked as verified
388
385
 
389
386
    // Let us break out of library directory hashing (the actual file scanning
390
387
    // stuff is in TrackCollection::importDirectory)
391
 
    m_libraryScanMutex.lock();
392
 
    bool cancel = m_bCancelLibraryScan;
393
 
    m_libraryScanMutex.unlock();
394
 
    if (cancel) {
 
388
    if (m_bCancelLibraryScan) {
395
389
        return false;
396
390
    }
397
391