Skip to content

Commit

Permalink
Merge pull request #117 from ascmitc/dev/fix113
Browse files Browse the repository at this point in the history
(Temporary) fix for issue #113.
  • Loading branch information
ptrpfn authored Feb 15, 2022
2 parents a44e928 + 70c0f37 commit a69bfa4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions ascmhl/cli/ascmhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def update(*args, **kwargs):
mhltool_cli.add_command(commands.flatten)
mhltool_cli.add_command(commands.info)
mhltool_cli.add_command(commands.xsd_schema_check)
mhltool_cli.add_command(commands.hash)


if __name__ == "__main__":
Expand Down
18 changes: 18 additions & 0 deletions ascmhl/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,24 @@ def _compare_and_log_directory_hashes(
# TODO def verify_single_file_subcommand(root_path, verbose):


@click.command()
@click.argument("file_path", type=click.Path(exists=True))
@click.option(
"--hash_format",
"-h",
type=click.Choice(ascmhl_supported_hashformats),
multiple=False,
required=True,
help="Algorithm",
)
def hash(file_path, hash_format):
"""
Create and print a hash value for a file
"""
result = hash_file(file_path, hash_format)
logger.info(hash_format + " (" + file_path + ") = " + result)


@click.command()
@click.argument("root_path", type=click.Path(exists=True))
@click.option(
Expand Down
8 changes: 7 additions & 1 deletion ascmhl/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,13 @@ def _resolve_hash_list_references(self) -> None:
history = self.child_history_mappings[reference_path]
referenced_hash_list = history.hash_list_with_file_name(os.path.basename(reference.path))
assert referenced_hash_list is not None
assert referenced_hash_list.generate_reference_hash() == reference.reference_hash
generated_hash = referenced_hash_list.generate_reference_hash()
if generated_hash != reference.reference_hash:
logger.error("ASC MHL file: " + hash_list.file_path)
logger.error(' referenced manifest file "' + referenced_hash_list.file_path + '"')
logger.error(" should have hash: " + reference.reference_hash)
logger.error(" but file has hash: " + generated_hash)

hash_list.referenced_hash_lists.append(referenced_hash_list)

# writing new generations
Expand Down

0 comments on commit a69bfa4

Please sign in to comment.