zola icon indicating copy to clipboard operation
zola copied to clipboard

add get_hash function

Open n-tux-tmp opened this issue 2 years ago • 6 comments

Hello,

I saw the Discourse topic which got no answers yet, so I decided to give it a try (as I need this feature myself).

It’s basically a rough copy of get_file_hash but it takes a string literal in parameter instead of a file. It was easier to adapt this function (and tests/documentation) than writing a filter instead. I hope this implementation still satisfies your expectations.

Sanity check:

  • [x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • [x] Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • [x] Have you created/updated the relevant documentation page(s)?

n-tux-tmp avatar Aug 13 '22 11:08 n-tux-tmp

Can you rebase the PR?

Keats avatar Aug 16 '22 06:08 Keats

Done!

n-tux-tmp avatar Aug 16 '22 08:08 n-tux-tmp

I reworked the PR to merge get_hash and get_file_hash into a common function (process_hashes) to minimize the amount of duplicated lines of code.

Though I couldn’t completely get rid of compute_file_hash because another function is using it and I have no clue how to get around those and_then()… Sorry for my lack of experience.

n-tux-tmp avatar Aug 16 '22 22:08 n-tux-tmp

Any chance you can rebase + fix conflict? I'll merge it after, it looks good.

Keats avatar Aug 24 '22 20:08 Keats

Should be fine now :)

n-tux-tmp avatar Aug 25 '22 21:08 n-tux-tmp

As requested, I removed the get_file_hash function and added path argument to get_hash. I’ve updated the documentation and tests to reflect this change.

(I also managed to get rid of compute_file_hash somehow)

n-tux-tmp avatar Aug 30 '22 08:08 n-tux-tmp