Skip to content

Commit

Permalink
fix: Manjaro updater sometimes having different checksum hashing algo…
Browse files Browse the repository at this point in the history
…rithms
  • Loading branch information
JoshuaVandaele committed Feb 5, 2024
1 parent ccd7324 commit e32f34f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
42 changes: 30 additions & 12 deletions modules/updaters/Manjaro.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

from modules.exceptions import VersionNotFoundError
from modules.updaters.GenericUpdater import GenericUpdater
from modules.utils import parse_hash, sha512_hash_check
from modules.utils import (
md5_hash_check,
parse_hash,
sha512_hash_check,
sha256_hash_check,
)

DOMAIN = "https://gitlab.manjaro.org"
DOWNLOAD_PAGE_URL = f"{DOMAIN}/web/iso-info/-/raw/master/file-info.json"
FILE_NAME = "manjaro-[[EDITION]]-[[VER]]-linux61.iso"
FILE_NAME = "manjaro-[[EDITION]]-[[VER]]-linux.iso"


class Manjaro(GenericUpdater):
Expand Down Expand Up @@ -50,16 +55,29 @@ def _get_download_link(self) -> str:
return self.file_info_json["releases"][self.edition]["image"]

def check_integrity(self) -> bool:
sha512_url = self.file_info_json["releases"][self.edition]["checksum"]

sha512_sums = requests.get(sha512_url).text

sha512_sum = parse_hash(sha512_sums, [], 0)

return sha512_hash_check(
self._get_complete_normalized_file_path(absolute=True),
sha512_sum,
)
checksum_url = self.file_info_json["releases"][self.edition]["checksum"]

checksums = requests.get(checksum_url).text

checksum = parse_hash(checksums, [], 0)

if checksum_url.endswith(".sha512"):
return sha512_hash_check(
self._get_complete_normalized_file_path(absolute=True),
checksum,
)
elif checksum_url.endswith(".sha256"):
return sha256_hash_check(
self._get_complete_normalized_file_path(absolute=True),
checksum,
)
elif checksum_url.endswith(".md5"):
return md5_hash_check(
self._get_complete_normalized_file_path(absolute=True),
checksum,
)
else:
raise ValueError("Unknown checksum type")

@cache
def _get_latest_version(self) -> list[str]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name="sisou", # Required
version="1.1.1", # Required
version="1.1.2", # Required
description="A powerful tool to conveniently update all of your ISO files!", # Optional
long_description=long_description, # Optional
long_description_content_type="text/markdown", # Optional
Expand Down

0 comments on commit e32f34f

Please sign in to comment.