From 9bdb0bdeffa5e4b6da9e3f6d3c1b79c506005fc5 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 31 May 2021 22:29:49 +0200 Subject: [PATCH] Fix path hash bug on unix --- src/loading/fs.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/loading/fs.rs b/src/loading/fs.rs index a37d96300..ac3f37065 100644 --- a/src/loading/fs.rs +++ b/src/loading/fs.rs @@ -195,8 +195,13 @@ fn load(cache: &mut FileCache, path: &Path) -> Option { /// Create a hash that is the same for all paths pointing to the same file. fn hash(path: &Path) -> Option { let file = File::open(path).ok()?; - let handle = Handle::from_file(file).ok()?; - Some(FileHash(fxhash::hash64(&handle))) + let meta = file.metadata().ok()?; + if meta.is_file() { + let handle = Handle::from_file(file).ok()?; + Some(FileHash(fxhash::hash64(&handle))) + } else { + None + } } #[cfg(test)]