Skip to content

Commit

Permalink
Library scan: report rediscovered tracks, fix report of missing tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jul 29, 2024
1 parent b196c4e commit 2c254d5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/library/library_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ struct LibraryScanResultSummary {
int numNewTracks;
int numMovedTracks;
int numMissingTracks;
int numRediscoveredTracks;
int tracksTotal;
};
21 changes: 17 additions & 4 deletions src/library/scanner/libraryscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ void LibraryScanner::slotStartScan() {
QSet<QString> trackLocations = m_trackDao.getAllTrackLocations();
// Store number of existing tracks so we can calculat the number
// of missing tracks in slotFinishUnhashedScan().
m_numPreviousExistingTrackLocations = m_trackDao.getAllExistingTrackLocations().size();
m_previouslyMissingTrackLocations = m_trackDao.getAllMissingTrackLocations();
m_numPreviouslyExistingTrackLocations = m_trackDao.getAllExistingTrackLocations().size();
QHash<QString, mixxx::cache_key_t> directoryHashes = m_libraryHashDao.getDirectoryHashes();
QRegularExpression extensionFilter(SoundSourceProxy::getSupportedFileNamesRegex());
QRegularExpression coverExtensionFilter =
Expand Down Expand Up @@ -433,9 +434,16 @@ void LibraryScanner::slotFinishUnhashedScan() {
const int numScannedDirs = m_scannerGlobal->numScannedDirectories();
const int numVerifiedTracks = static_cast<int>(m_scannerGlobal->verifiedTracks().size());
const int numNewTracks = m_scannerGlobal->addedTracks().size() - m_numRelocatedTracks;
const int numMissingTracks = m_numPreviousExistingTrackLocations +
numNewTracks -
m_trackDao.getAllExistingTrackLocations().size();
const int numMissingTracks = m_trackDao.getAllMissingTrackLocations().size();
const QSet<QString> existingTrackLocations = m_trackDao.getAllExistingTrackLocations();
int numRediscoveredTracks = 0;
for (const QString& loc : m_previouslyMissingTrackLocations) {

Check failure on line 440 in src/library/scanner/libraryscanner.cpp

View workflow job for this annotation

GitHub Actions / clazy

c++11 range-loop might detach Qt container (QSet) [-Wclazy-range-loop-detach]
if (existingTrackLocations.contains(loc)) {
numRediscoveredTracks++;
}
}
const int tracksTotal = existingTrackLocations.size();

qInfo() << "-------------------------------------------------------";
qInfo("Library scan finished after %s", durationString.toLocal8Bit().constData());
qInfo(" %d unchanged directories", numVerifiedDirs);
Expand All @@ -444,6 +452,9 @@ void LibraryScanner::slotFinishUnhashedScan() {
qInfo(" %d new tracks", numNewTracks);
qInfo(" %d moved tracks", m_numRelocatedTracks);
qInfo(" %d missing tracks", numMissingTracks);
qInfo(" %d missing tracks", numMissingTracks);
qInfo(" %d rediscovered tracks", numRediscoveredTracks);
qInfo(" %d tracks total", tracksTotal);
qInfo() << "-------------------------------------------------------";

LibraryScanResultSummary result;
Expand All @@ -454,6 +465,8 @@ void LibraryScanner::slotFinishUnhashedScan() {
result.numNewTracks = numNewTracks;
result.numMovedTracks = m_numRelocatedTracks;
result.numMissingTracks = numMissingTracks;
result.numRediscoveredTracks = numRediscoveredTracks;
result.tracksTotal = tracksTotal;

m_scannerGlobal.clear();
changeScannerState(FINISHED);
Expand Down
3 changes: 2 additions & 1 deletion src/library/scanner/libraryscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class LibraryScanner : public QThread {
// this is accessed main and LibraryScanner thread
volatile ScannerState m_state;

int m_numPreviousExistingTrackLocations;
QSet<QString> m_previouslyMissingTrackLocations;
int m_numPreviouslyExistingTrackLocations;
int m_numRelocatedTracks;

QList<mixxx::FileInfo> m_libraryRootDirs;
Expand Down
33 changes: 21 additions & 12 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,26 +1148,35 @@ void MixxxMainWindow::slotHelpAbout() {

void MixxxMainWindow::slotLibraryScanSummaryDlg(const LibraryScanResultSummary& result) {
QString summary =
tr("Scan took %1.").arg(result.durationString) + QStringLiteral("\n\n");
tr("Scan took %1.").arg(result.durationString) + QStringLiteral("<br><br>");
if ((result.numNewTracks + result.numMovedTracks + result.numMissingTracks) == 0) {
summary += tr("No changes were detected.");
summary += tr("No changes were detected.") +
QStringLiteral("<br><b>") +
tr("%1 tracks in total").arg(result.tracksTotal) +
QStringLiteral("</b>");
} else {
summary += tr("%1 verified directories").arg(result.numVerifiedDirs) +
QStringLiteral("\n") +
QStringLiteral("<br>") +
tr("%1 scanned directories").arg(result.numScannedDirs) +
QStringLiteral("\n") +
QStringLiteral("<br>") +
tr("%1 verified tracks").arg(result.numVerifiedTracks) +
QStringLiteral("\n") +
QStringLiteral("<br>") +
tr("%1 new tracks found").arg(result.numNewTracks) +
QStringLiteral("\n") +
QStringLiteral("<br>") +
tr("%1 moved tracks detected").arg(result.numMovedTracks) +
QStringLiteral("\n") +
tr("%1 are missing").arg(result.numMissingTracks);
QStringLiteral("<br>") +
tr("%1 tracks are missing").arg(result.numMissingTracks) +
QStringLiteral("<br>") +
tr("%1 tracks have been rediscovered").arg(result.numRediscoveredTracks) +
QStringLiteral("<br><br><b>") +
tr("%1 tracks in total").arg(result.tracksTotal) +
QStringLiteral("</b>");
}
QMessageBox* msg = new QMessageBox();
msg->setWindowTitle(tr("Library scan finished"));
msg->setText(summary);
msg->show();
QMessageBox* pMsg = new QMessageBox();
pMsg->setTextFormat(Qt::RichText);
pMsg->setWindowTitle(tr("Library scan finished"));
pMsg->setText(summary);
pMsg->show();
}

void MixxxMainWindow::slotShowKeywheel(bool toggle) {
Expand Down

0 comments on commit 2c254d5

Please sign in to comment.