summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-05-31 22:29:49 +0200
committerLaurenz <laurmaedje@gmail.com>2021-05-31 22:33:40 +0200
commit9bdb0bdeffa5e4b6da9e3f6d3c1b79c506005fc5 (patch)
tree5a4a056bfec9c36bf7bc4c3a8d45c86c554c112d
parent37e08460377498165f421a522cb4eb1bb4e246b7 (diff)
Fix path hash bug on unix
-rw-r--r--src/loading/fs.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/loading/fs.rs b/src/loading/fs.rs
index a37d9630..ac3f3706 100644
--- a/src/loading/fs.rs
+++ b/src/loading/fs.rs
@@ -195,8 +195,13 @@ fn load(cache: &mut FileCache, path: &Path) -> Option<Buffer> {
/// Create a hash that is the same for all paths pointing to the same file.
fn hash(path: &Path) -> Option<FileHash> {
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)]