Fixed crash when a library is set with a trailing /, fixes #552
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
namespace lms::db
|
||||
{
|
||||
MediaLibrary::MediaLibrary(const std::filesystem::path& p, std::string_view name)
|
||||
: _path{ p }
|
||||
, _name{ std::string{ name, 0, maxNameLength } }
|
||||
: _name{ std::string{ name, 0, maxNameLength } }
|
||||
{
|
||||
setPath(p);
|
||||
}
|
||||
|
||||
MediaLibrary::pointer MediaLibrary::create(Session& session, const std::filesystem::path& p, std::string_view name)
|
||||
@@ -77,4 +77,13 @@ namespace lms::db
|
||||
func(mediaLibrary);
|
||||
});
|
||||
}
|
||||
|
||||
void MediaLibrary::setPath(const std::filesystem::path& p)
|
||||
{
|
||||
assert(p.is_absolute());
|
||||
if (!p.has_filename() && p.has_parent_path())
|
||||
_path = p.parent_path();
|
||||
else
|
||||
_path = p;
|
||||
}
|
||||
} // namespace lms::db
|
||||
|
||||
Reference in New Issue
Block a user