Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
games647 committed Sep 18, 2024
1 parent 43eee1d commit babb21e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/checkers/urlchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,27 @@ def extract_version(checker_data, url):

return m.group(1)


def is_same_version(checker_data, current_url, new_version):
"""
Check if the new application version is the same with the current one. If the version number could be extracted,
those strings are compared with each other to be resilient against load-balanced urls pointing to the same file.
Check if the new application version is the same with the current one. If the
version number could be extracted, those strings are compared with each other
to be resilient against load-balanced urls pointing to the same file.
"""
if new_version is None or new_version.version is None:
# No pattern given or failed parsing the new version, so check only if the url is different
if new_version.version is None:
# No pattern given or failed parsing the new version, so check only
# if the url is different
return current_url == new_version.url

current_version_string = extract_version(checker_data, current_url)
if current_version_string is None:
# If the pattern failed to apply to the old/current version, check again only the url
# Otherwise we would compare None values
# If the pattern failed to apply to the old/current version,
# check again only the url. Otherwise we would compare None values
return current_url == new_version.url

return current_version_string == new_version.version


class URLChecker(Checker):
PRIORITY = 99
CHECKER_DATA_TYPE = "rotating-url"
Expand Down Expand Up @@ -154,7 +158,9 @@ async def check(self, external_data: ExternalBase):
if not is_rotating:
new_version = new_version._replace(url=url) # pylint: disable=no-member

same_version = is_same_version(external_data.checker_data, external_data.current_version.url, new_version)
same_version = is_same_version(
external_data.checker_data, external_data.current_version.url, new_version
)
external_data.set_new_version(
new_version,
is_update=is_rotating and not same_version,
Expand Down
5 changes: 2 additions & 3 deletions src/lib/externaldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,8 @@ def json(self) -> t.Dict[str, t.Any]:
def matches(self, other: ExternalFile):
for i in (self, other):
assert i.checksum is None or isinstance(i.checksum, MultiDigest), i.checksum
return (
self.checksum == other.checksum
and (self.size is None or other.size is None or self.size == other.size)
return self.checksum == other.checksum and (
self.size is None or other.size is None or self.size == other.size
)

def is_same_version(self, other: ExternalFile):
Expand Down

0 comments on commit babb21e

Please sign in to comment.