From fa04eb67dbd1e3fb6b58d855a4396d0d1e266f5f Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 29 Jun 2023 19:38:05 +0200 Subject: [PATCH] Convert old embedded and unset art in the new schema --- data/schema/schema-17.sql | 8 ++++++++ src/core/song.cpp | 30 ++---------------------------- src/core/song.h | 2 -- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/data/schema/schema-17.sql b/data/schema/schema-17.sql index 8e7bbf6c9..658910f3d 100644 --- a/data/schema/schema-17.sql +++ b/data/schema/schema-17.sql @@ -34,4 +34,12 @@ ALTER TABLE playlist_items ADD COLUMN art_embedded INTEGER DEFAULT 0; ALTER TABLE playlist_items ADD COLUMN art_unset INTEGER DEFAULT 0; +UPDATE songs SET art_embedded = 1 WHERE art_automatic = 'file:(embedded)'; + +UPDATE songs SET art_automatic = '' WHERE art_automatic = 'file:(embedded)'; + +UPDATE songs SET art_unset = 1 WHERE art_manual = 'file:(unset)'; + +UPDATE songs SET art_manual = '' WHERE art_manual = 'file:(unset)'; + UPDATE schema_version SET version=17; diff --git a/src/core/song.cpp b/src/core/song.cpp index b63c3dbe6..bafc11822 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -154,9 +154,6 @@ const QString Song::kFtsColumnSpec = Song::kFtsColumns.join(", "); const QString Song::kFtsBindSpec = Utilities::Prepend(":", Song::kFtsColumns).join(", "); const QString Song::kFtsUpdateSpec = Utilities::Updateify(Song::kFtsColumns).join(", "); -const QString Song::kManuallyUnsetCover = "(unset)"; -const QString Song::kEmbeddedCover = "(embedded)"; - const QRegularExpression Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption); const QRegularExpression Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster|Explicit) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption); const QRegularExpression Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$", QRegularExpression::CaseInsensitiveOption); @@ -1315,33 +1312,10 @@ void Song::InitFromQuery(const SqlRow &q, const bool reliable_metadata) { d->compilation_off_ = q.ValueToBool("compilation_off"); d->art_embedded_ = q.ValueToBool("art_embedded"); + d->art_automatic_ = QUrl::fromEncoded(q.ValueToString("art_automatic").toUtf8()); + d->art_manual_ = QUrl::fromEncoded(q.ValueToString("art_manual").toUtf8()); d->art_unset_ = q.ValueToBool("art_unset"); - const QString art_automatic = q.ValueToString("art_automatic"); - if (!art_automatic.isEmpty()) { - QUrl url_art_automatic = QUrl::fromEncoded(art_automatic.toUtf8()); - if (url_art_automatic.isValid()) { - if (url_art_automatic.path() == kEmbeddedCover) { - d->art_embedded_ = true; - } - else { - d->art_automatic_ = url_art_automatic; - } - } - } - const QString art_manual = q.ValueToString("art_manual"); - if (!art_manual.isEmpty()) { - const QUrl url_art_manual = QUrl::fromEncoded(art_manual.toUtf8()); - if (url_art_manual.isValid()) { - if (url_art_manual.path() == kManuallyUnsetCover) { - d->art_unset_ = true; - } - else { - d->art_manual_ = url_art_manual; - } - } - } - d->cue_path_ = q.ValueToString("cue_path"); d->rating_ = q.ValueToFloat("rating"); diff --git a/src/core/song.h b/src/core/song.h index 93b24d60a..575e1df27 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -427,8 +427,6 @@ class Song { QString AlbumKey() const; private: - static const QString kManuallyUnsetCover; - static const QString kEmbeddedCover; struct Private; static QString sortable(const QString &v);