Fixed crash when a library is set with a trailing /, fixes #552

This commit is contained in:
emeric
2024-11-14 23:18:00 +01:00
parent ffc780d350
commit 7b4791005a
5 changed files with 23 additions and 5 deletions
+11 -2
View File
@@ -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