mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
Attempt order invariance
This commit is contained in:
parent
45b824346c
commit
73e7c3e560
2 changed files with 10 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::{
|
||||
fs::read_to_string,
|
||||
hash::{DefaultHasher, Hash, Hasher},
|
||||
hash::{DefaultHasher, Hasher},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
|
@ -16,8 +16,6 @@ fn main() {
|
|||
if contents.trim() == hash.to_string() {
|
||||
return;
|
||||
}
|
||||
|
||||
panic!("Hashes don't match {} != {}", contents, hash.to_string());
|
||||
}
|
||||
|
||||
// Otherwise, generate the bindings and write the new hash to disk
|
||||
|
@ -30,8 +28,8 @@ fn main() {
|
|||
}
|
||||
|
||||
/// Hashes the contents of a directory
|
||||
fn hash_dir(dir: &str) -> u64 {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
fn hash_dir(dir: &str) -> u128 {
|
||||
let mut out = 0_128;
|
||||
|
||||
for entry in std::fs::read_dir(dir).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
|
@ -45,11 +43,14 @@ fn hash_dir(dir: &str) -> u64 {
|
|||
continue;
|
||||
}
|
||||
|
||||
let contents = std::fs::read(&path).unwrap();
|
||||
contents.hash(&mut hasher);
|
||||
// Hash the contents of the file and then add it to the overall hash
|
||||
// This makes us order invariant
|
||||
let mut hasher = DefaultHasher::new();
|
||||
hasher.write(&std::fs::read(&path).unwrap());
|
||||
out += hasher.finish() as u128;
|
||||
}
|
||||
|
||||
hasher.finish()
|
||||
out
|
||||
}
|
||||
|
||||
// okay...... so tsc might fail if the user doesn't have it installed
|
||||
|
|
|
@ -1 +1 @@
|
|||
6653358969285642234
|
||||
63611502429846612446
|
Loading…
Add table
Reference in a new issue