Made length checks more robusts + bumped sizes, fixes #496
This commit is contained in:
@@ -183,10 +183,10 @@ namespace lms::db
|
||||
} // namespace
|
||||
|
||||
Artist::Artist(const std::string& name, const std::optional<core::UUID>& MBID)
|
||||
: _name{ std::string(name, 0, _maxNameLength) }
|
||||
, _sortName{ _name }
|
||||
, _MBID{ MBID ? MBID->getAsString() : "" }
|
||||
: _MBID{ MBID ? MBID->getAsString() : "" }
|
||||
{
|
||||
setName(name);
|
||||
_sortName = _name;
|
||||
}
|
||||
|
||||
Artist::pointer Artist::create(Session& session, const std::string& name, const std::optional<core::UUID>& MBID)
|
||||
@@ -360,9 +360,19 @@ namespace lms::db
|
||||
return res;
|
||||
}
|
||||
|
||||
void Artist::setSortName(const std::string& sortName)
|
||||
void Artist::setName(std::string_view name)
|
||||
{
|
||||
_sortName = std::string(sortName, 0, _maxNameLength);
|
||||
_name.assign(name, 0, _maxNameLength);
|
||||
if (name.size() > _maxNameLength)
|
||||
LMS_LOG(DB, WARNING, "Artist name too long, truncated to '" << _name << "'");
|
||||
}
|
||||
|
||||
void Artist::setSortName(std::string_view sortName)
|
||||
{
|
||||
_sortName.assign(sortName, 0, _maxNameLength);
|
||||
|
||||
if (sortName.size() > _maxNameLength)
|
||||
LMS_LOG(DB, WARNING, "Artist sort name too long, truncated to '" << _sortName << "'");
|
||||
}
|
||||
|
||||
void Artist::setImage(ObjectPtr<Image> image)
|
||||
|
||||
Reference in New Issue
Block a user