Fix circular dependency with UriHolder by using abstract _clear_uri_set

- instead of abstract _set_uri_set
- removed circular dependency on UriHolder.add_uris
master
Felix Stupp 11 months ago
parent dde3395d14
commit 2f132ee701
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -420,9 +420,8 @@ class MediaElement(db.Entity, UriHolder, Tagable):
def _uri_set(self) -> Set[str]:
return {m.uri for m in self.__uri_list}
def _set_uri_set(self, uri_set: Set[str]) -> None:
def _clear_uri_set(self) -> None:
self.__uri_list = set()
self.add_uris(uri_set)
### for Tagable
@ -749,9 +748,8 @@ class MediaCollection(db.Entity, UriHolder, Tagable):
def _uri_set(self) -> Set[str]:
return {m.uri for m in self.__uri_set}
def _set_uri_set(self, uri_set: Set[str]) -> None:
def _clear_uri_set(self) -> None:
self.__uri_set = set()
self.add_uris(uri_set)
### for Tagable

@ -20,7 +20,7 @@ class UriHolder:
"""Returns the uri set of this object in a naive way."""
@abstractmethod
def _set_uri_set(self, uri_set: Set[str]) -> None:
def _clear_uri_set(self) -> None:
"""Sets the uri set of this object in a naive way."""
@abstractmethod
@ -72,8 +72,8 @@ class UriHolder:
return ret
def set_as_only_uri(self, uri: str) -> None:
self._set_uri_set({uri}) # might fail, so try first
self._set_primary_uri(uri)
self._clear_uri_set()
self.set_primary_uri(uri)
def add_single_uri(self, uri: str) -> bool:
return self._add_uri_to_set(uri)

Loading…
Cancel
Save