Skip to content

Commit

Permalink
fix(core): hash files properly by reading the whole file
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Dec 7, 2023
1 parent d11a22b commit 70c76e5
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/nx/src/native/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ pub fn hash_file(file: String) -> Option<String> {
#[inline]
pub fn hash_file_path<P: AsRef<Path>>(path: P) -> Option<String> {
let path = path.as_ref();
let Ok(file) = File::open(path) else {
trace!("could not open file: {path:?}");
let Ok(content) = std::fs::read(path) else {
trace!("Failed to read file: {:?}", path);
return None;
};

let mut buffer = BufReader::new(file);
let Ok(content) = buffer.fill_buf() else {
trace!("could not read file: {path:?}");
return None;
};

Some(hash(content))
Some(hash(&content))
}

#[cfg(test)]
Expand Down

0 comments on commit 70c76e5

Please sign in to comment.