db/upnp/Object: root nodes are allowed to omit parent_id and name

This fixes compatibility with Plex DLNA.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/851
This commit is contained in:
Max Kellermann
2020-07-06 21:35:31 +02:00
parent 5ece9685c2
commit 00789de7d4
2 changed files with 11 additions and 1 deletions

View File

@@ -89,9 +89,18 @@ public:
tag.Clear();
}
gcc_pure
bool IsRoot() const noexcept {
return type == Type::CONTAINER && id == "0";
}
gcc_pure
bool Check() const noexcept {
return !id.empty() && !parent_id.empty() && !name.empty() &&
return !id.empty() &&
/* root nodes don't need a parent id and a
name */
(IsRoot() || (!parent_id.empty() &&
!name.empty())) &&
(type != UPnPDirObject::Type::ITEM ||
item_class != UPnPDirObject::ItemClass::UNKNOWN);
}