build sha256sum

This commit is contained in:
Jan-Marten Brüggemann 2024-09-14 00:07:56 +02:00
parent 7cb60149d3
commit d153e41715
2 changed files with 6 additions and 2 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.conda .conda
*.zim *.zim
*.part *.part
*.sha256sum

View file

@ -75,8 +75,7 @@ def retreive_filelist(session: requests.Session, url: str, cache_file: str = "",
def find_wiki_files(filelist: list, wiki: str) -> list: def find_wiki_files(filelist: list, wiki: str) -> list:
result = list() result = list()
for file in filelist: for file in filelist:
url = urljoin(file[0], file[1]) if file[1].startswith(wiki):
if wiki in url:
result.append(file) result.append(file)
return result return result
@ -199,6 +198,10 @@ def download_wiki(session: requests.Session, title: str, src: str, dst: str):
if digest_value != sha256.digest(): if digest_value != sha256.digest():
raise SystemExit(f"Checksum Error for {title}. Aborting.") 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) os.rename(dst + '.part', dst)
def main(): def main():