Fix marking CUE songs available
This commit is contained in:
@@ -838,18 +838,19 @@ Song CollectionBackend::GetSongByUrl(const QUrl &url, const qint64 beginning) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SongList CollectionBackend::GetSongsByUrl(const QUrl &url) {
|
SongList CollectionBackend::GetSongsByUrl(const QUrl &url, const bool unavailable) {
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
q.prepare(QString("SELECT ROWID, " + Song::kColumnSpec + " FROM %1 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = 0").arg(songs_table_));
|
q.prepare(QString("SELECT ROWID, " + Song::kColumnSpec + " FROM %1 WHERE (url = :url1 OR url = :url2 OR url = :url3 OR url = :url4) AND unavailable = :unavailable").arg(songs_table_));
|
||||||
|
|
||||||
q.bindValue(":url1", url);
|
q.bindValue(":url1", url);
|
||||||
q.bindValue(":url2", url.toString());
|
q.bindValue(":url2", url.toString());
|
||||||
q.bindValue(":url3", url.toString(QUrl::FullyEncoded));
|
q.bindValue(":url3", url.toString(QUrl::FullyEncoded));
|
||||||
q.bindValue(":url4", url.toEncoded());
|
q.bindValue(":url4", url.toEncoded());
|
||||||
|
q.bindValue(":unavailable", (unavailable ? 1 : 0));
|
||||||
|
|
||||||
SongList songs;
|
SongList songs;
|
||||||
if (q.exec()) {
|
if (q.exec()) {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class CollectionBackendInterface : public QObject {
|
|||||||
virtual Song GetSongById(const int id) = 0;
|
virtual Song GetSongById(const int id) = 0;
|
||||||
|
|
||||||
// Returns all sections of a song with the given filename. If there's just one section the resulting list will have it's size equal to 1.
|
// Returns all sections of a song with the given filename. If there's just one section the resulting list will have it's size equal to 1.
|
||||||
virtual SongList GetSongsByUrl(const QUrl &url) = 0;
|
virtual SongList GetSongsByUrl(const QUrl &url, const bool unavailable = false) = 0;
|
||||||
// Returns a section of a song with the given filename and beginning. If the section is not present in collection, returns invalid song.
|
// Returns a section of a song with the given filename and beginning. If the section is not present in collection, returns invalid song.
|
||||||
// Using default beginning value is suitable when searching for single-section songs.
|
// Using default beginning value is suitable when searching for single-section songs.
|
||||||
virtual Song GetSongByUrl(const QUrl &url, const qint64 beginning = 0) = 0;
|
virtual Song GetSongByUrl(const QUrl &url, const qint64 beginning = 0) = 0;
|
||||||
@@ -170,7 +170,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
|||||||
SongList GetSongsById(const QStringList &ids);
|
SongList GetSongsById(const QStringList &ids);
|
||||||
SongList GetSongsByForeignId(const QStringList &ids, const QString &table, const QString &column);
|
SongList GetSongsByForeignId(const QStringList &ids, const QString &table, const QString &column);
|
||||||
|
|
||||||
SongList GetSongsByUrl(const QUrl &url) override;
|
SongList GetSongsByUrl(const QUrl &url, const bool unavailable = false) override;
|
||||||
Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) override;
|
Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) override;
|
||||||
|
|
||||||
void AddDirectory(const QString &path) override;
|
void AddDirectory(const QString &path) override;
|
||||||
|
|||||||
@@ -470,8 +470,15 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing has changed - mark the song available without re-scanning
|
// Nothing has changed - mark the song available without re-scanning
|
||||||
if (matching_song.is_unavailable()) t->readded_songs << matching_song;
|
if (matching_song.is_unavailable()) {
|
||||||
|
if (matching_song.has_cue()) {
|
||||||
|
t->readded_songs << backend_->GetSongsByUrl(QUrl::fromLocalFile(file), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t->readded_songs << matching_song;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user