From d153e417151abf76c1d8f99580fbd3a0f2708612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Marten=20Br=C3=BCggemann?= Date: Sat, 14 Sep 2024 00:07:56 +0200 Subject: [PATCH] build sha256sum --- .gitignore | 1 + sync_kiwix.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 58a098a..5ebb6dc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .conda *.zim *.part +*.sha256sum \ No newline at end of file diff --git a/sync_kiwix.py b/sync_kiwix.py index ae9baba..f75447a 100644 --- a/sync_kiwix.py +++ b/sync_kiwix.py @@ -75,8 +75,7 @@ def retreive_filelist(session: requests.Session, url: str, cache_file: str = "", def find_wiki_files(filelist: list, wiki: str) -> list: result = list() for file in filelist: - url = urljoin(file[0], file[1]) - if wiki in url: + if file[1].startswith(wiki): result.append(file) return result @@ -199,6 +198,10 @@ def download_wiki(session: requests.Session, title: str, src: str, dst: str): if digest_value != sha256.digest(): raise SystemExit(f"Checksum Error for {title}. Aborting.") + sha256sum = sha256.hexdigest() + with open(dst + '.sha256sum', 'w') as file: + file.write(f"{sha256sum} {dst}\n") + os.rename(dst + '.part', dst) def main():