Skip to content

Commit e0fda67

Browse files
committed
Auto merge of #14728 - weihanglo:checksum, r=ehuss
refactor(fingerprint): avoid unnecessary fopen calls
2 parents 944559f + 692d830 commit e0fda67

File tree

1 file changed

+3
-3
lines changed
  • src/cargo/core/compiler/fingerprint

1 file changed

+3
-3
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,16 +2017,16 @@ where
20172017
let Ok(current_file_len) = fs::metadata(&path).map(|m| m.len()) else {
20182018
return Some(StaleItem::FailedToReadMetadata(path.to_path_buf()));
20192019
};
2020-
let Ok(file) = File::open(path) else {
2021-
return Some(StaleItem::MissingFile(path.to_path_buf()));
2022-
};
20232020
if current_file_len != file_len {
20242021
return Some(StaleItem::FileSizeChanged {
20252022
path: path.to_path_buf(),
20262023
new_size: current_file_len,
20272024
old_size: file_len,
20282025
});
20292026
}
2027+
let Ok(file) = File::open(path) else {
2028+
return Some(StaleItem::MissingFile(path.to_path_buf()));
2029+
};
20302030
let Ok(checksum) = Checksum::compute(prior_checksum.algo, file) else {
20312031
return Some(StaleItem::UnableToReadFile(path.to_path_buf()));
20322032
};

0 commit comments

Comments
 (0)