Skip to content

Commit

Permalink
fix: better file comparisons with source_path fast path
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Mar 21, 2021
1 parent e3c1890 commit 3c12aa7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions beet/core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ def ensure_deserialized(self) -> ValueType:
return content

def __eq__(self, other: Any) -> bool:
if type(self) != type(other):
return NotImplemented

return (
type(self) == type(other)
and self.ensure_serialized() == other.ensure_serialized()
(self.source_path is not None and self.source_path == other.source_path)
or self.ensure_serialized() == other.ensure_serialized()
or self.ensure_deserialized() == other.ensure_deserialized()
)

@classmethod
Expand Down Expand Up @@ -268,9 +272,6 @@ def to_str(cls, content: ValueType) -> str:
def from_str(cls, content: str) -> ValueType:
return json.loads(content)

def __eq__(self, other: Any) -> bool:
return type(self) == type(other) and self.data == other.data


class JsonFile(JsonFileBase[JsonDict]):
"""Class representing a json file."""
Expand Down

0 comments on commit 3c12aa7

Please sign in to comment.