-
Notifications
You must be signed in to change notification settings - Fork 996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement get_file_hash #1044
Implement get_file_hash #1044
Conversation
41194a6
to
671eaba
Compare
This is now two commits, with the first one fixing my previous blunders with The implementation has different functions Another option is to make the calls like fn compute_file_hash<T>(path: &PathBuf) -> result::Result<String, io::Error>
where
T: Digest + io::Write,
<T as Digest>::OutputSize: ops::Add,
<<T as Digest>::OutputSize as ops::Add>::Output: generic_array::ArrayLength<u8>
{
let mut file = fs::File::open(path)?;
let mut hasher = T::new();
io::copy(&mut file, &mut hasher)?;
Ok(format!("{:x}", hasher.result()))
} That would also add a direct dependency on Also, let me know if you'd rather have a separate PR and possibly a bug report for the first commit. |
Oh boy, the cache-busting is still broken on generated assets (compiled scss). |
671eaba
to
7731362
Compare
Ok, the final try. Both the cachebusting implementation and Hope this is good. |
The previous implementation looked for static files in the wrong place. Look in static_path, output_path and content_path. If file can't be found in any of them, print a warning to stderr and fall back to using a timestamp. Add a test to ensure it also works in practice, not just in theory.
7731362
to
52f7bc4
Compare
Oh, |
The windows build seems to be failing because the files in
This seems to be because git converts line endings on Windows.
|
Thanks for reviewing! Good points, I'll fix these. |
52f7bc4
to
bdcf143
Compare
I tried to fix the Windows tests by forcing |
Thanks! |
WARNING: contains a bug.As mentioned in #519, both the
cachebust
commit I previously posted and this one look for static files directly incontent_path
when they're really instatic/
. I'll fix that tonight if I have time.EDIT: it's fixed now, in the first commit.
IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one: