- Write in a new format if you use SHA512 checksum

- A version is bumbed
This commit is contained in:
Stepan Oksanichenko 2024-08-23 19:21:32 +03:00
parent c078cfb0a3
commit 1e8aafba61
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
2 changed files with 9 additions and 5 deletions

View File

@ -149,13 +149,17 @@ def main():
) )
out_fd = None out_fd = None
if args.append_metadata: if args.append_metadata:
file_mdoe = 'a' file_mode = 'a'
else: else:
file_mdoe = 'w' file_mode = 'w'
if args.output_metadata: if args.output_metadata:
out_fd = open(args.output_metadata, file_mdoe) out_fd = open(args.output_metadata, file_mode)
try: try:
for rel_path, checksum, checksum_type in iterator: for rel_path, checksum, checksum_type in iterator:
if args.sha512:
line_to_write = f'SHA512 ({rel_path}) = {checksum}\n'
else:
line_to_write = f'{checksum} {rel_path}\n'
file_path = normalize_path(rel_path) file_path = normalize_path(rel_path)
if not args.file: if not args.file:
real_checksum = get_file_checksum(file_path, checksum_type) real_checksum = get_file_checksum(file_path, checksum_type)
@ -172,7 +176,7 @@ def main():
else: else:
logging.info(f'{rel_path} is already uploaded: {file_url}') logging.info(f'{rel_path} is already uploaded: {file_url}')
if out_fd: if out_fd:
out_fd.write(f'{checksum} {rel_path}\n') out_fd.write(line_to_write)
finally: finally:
if out_fd: if out_fd:
out_fd.close() out_fd.close()

View File

@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fd:
setup( setup(
name="almalinux-git-utils", name="almalinux-git-utils",
version="0.0.2", version="0.0.3",
author="Eugene Zamriy", author="Eugene Zamriy",
author_email="ezamriy@almalinux.org", author_email="ezamriy@almalinux.org",
description="Utilities for working with the AlmaLinux OS Git server", description="Utilities for working with the AlmaLinux OS Git server",