Merge branch 'develop' into cmake
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
namespace Database {
|
||||
|
||||
#define LMS_DATABASE_VERSION 12
|
||||
#define LMS_DATABASE_VERSION 13
|
||||
|
||||
using Version = std::size_t;
|
||||
|
||||
@@ -151,6 +151,12 @@ CREATE TABLE IF NOT EXISTS "track_bookmark" (
|
||||
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
|
||||
ScanSettings::get(*this).modify()->incScanVersion();
|
||||
}
|
||||
else if (version == 12)
|
||||
{
|
||||
// Artist and release that have a baddly parsed name but a MBID had no chance to updat the name
|
||||
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
|
||||
ScanSettings::get(*this).modify()->incScanVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DB, ERROR) << "Database version " << version << " cannot be handled using migration";
|
||||
|
||||
@@ -71,8 +71,8 @@ class Artist : public Wt::Dbo::Dbo<Artist>
|
||||
static std::vector<IdType> getAllIdsWithClusters(Session& session, std::optional<std::size_t> limit = {});
|
||||
|
||||
// Accessors
|
||||
const std::string& getName(void) const { return _name; }
|
||||
std::optional<UUID> getMBID(void) const { return UUID::fromString(_MBID); }
|
||||
const std::string& getName(void) const { return _name; }
|
||||
std::optional<UUID> getMBID(void) const { return UUID::fromString(_MBID); }
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<IdType>& clusterIds = {}) const; // if non empty, get the releases that match all these clusters
|
||||
std::size_t getReleaseCount() const;
|
||||
@@ -86,7 +86,8 @@ class Artist : public Wt::Dbo::Dbo<Artist>
|
||||
// size is the max number of cluster per cluster type
|
||||
std::vector<std::vector<Wt::Dbo::ptr<Cluster>>> getClusterGroups(std::vector<Wt::Dbo::ptr<ClusterType>> clusterTypes, std::size_t size) const;
|
||||
|
||||
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
||||
void setName(std::string_view name) { _name = name; }
|
||||
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
||||
void setSortName(const std::string& sortName);
|
||||
|
||||
// Create
|
||||
|
||||
@@ -89,7 +89,7 @@ class Release : public Wt::Dbo::Dbo<Release>
|
||||
void setTotalTrackNumber(std::size_t num) { _totalTrackNumber = static_cast<int>(num); }
|
||||
|
||||
// Accessors
|
||||
std::string getName() const { return _name; }
|
||||
const std::string& getName() const { return _name; }
|
||||
std::optional<UUID> getMBID() const { return UUID::fromString(_MBID); }
|
||||
std::optional<std::size_t> getTotalTrackNumber() const;
|
||||
std::optional<std::size_t> getTotalDiscNumber() const;
|
||||
@@ -101,7 +101,8 @@ class Release : public Wt::Dbo::Dbo<Release>
|
||||
bool hasVariousArtists() const;
|
||||
std::vector<pointer> getSimilarReleases(std::optional<std::size_t> offset = {}, std::optional<std::size_t> count = {}) const;
|
||||
|
||||
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
||||
void setName(std::string_view name) { _name = name; }
|
||||
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
|
||||
|
||||
template<class Action>
|
||||
void persist(Action& a)
|
||||
|
||||
@@ -98,7 +98,14 @@ getOrCreateArtists(Session& session, const std::vector<MetaData::Artist>& artist
|
||||
{
|
||||
artist = Artist::getByMBID(session, *artistInfo.musicBrainzArtistID);
|
||||
if (!artist)
|
||||
{
|
||||
artist = Artist::create(session, artistInfo.name, artistInfo.musicBrainzArtistID);
|
||||
}
|
||||
else if (artist->getName() != artistInfo.name)
|
||||
{
|
||||
// Name may have been updated
|
||||
artist.modify()->setName(artistInfo.name);
|
||||
}
|
||||
|
||||
artists.emplace_back(std::move(artist));
|
||||
continue;
|
||||
@@ -139,7 +146,14 @@ getOrCreateRelease(Session& session, const MetaData::Album& album)
|
||||
{
|
||||
release = Release::getByMBID(session, *album.musicBrainzAlbumID);
|
||||
if (!release)
|
||||
{
|
||||
release = Release::create(session, album.name, album.musicBrainzAlbumID);
|
||||
}
|
||||
else if (release->getName() != album.name)
|
||||
{
|
||||
// Name may have been updated
|
||||
release.modify()->setName(album.name);
|
||||
}
|
||||
|
||||
return release;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user