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():