On Unix, when opening a file with std::fs::File::open(), the file is opened with O_RDONLY mode but the access timestamp in the file metadata is updated (see https://github.com/posborne/rust-systems-programming/blob/master/file-io.md and man 7 inode). In the case of infer, trying to infer a file type with infer::get_from_path should be without this side effect as it is on Windows where the file type can be deducted from the extension.
The way to do it is to open the file with the mode O_NOATIME, that can be done with the following code:
// We open the file without changing the access time in the metadata
let mode = (libc::O_RDONLY | libc::O_NOATIME).try_into().unwrap();
let mut file = OpenOptions::new().mode(mode).open(entry.path())?;
Please change infer::get_from_path to remove this side effect.
On Unix, when opening a file with
std::fs::File::open()
, the file is opened withO_RDONLY
mode but the access timestamp in the file metadata is updated (see https://github.com/posborne/rust-systems-programming/blob/master/file-io.md andman 7 inode
). In the case of infer, trying to infer a file type withinfer::get_from_path
should be without this side effect as it is on Windows where the file type can be deducted from the extension.The way to do it is to open the file with the mode
O_NOATIME
, that can be done with the following code:Please change
infer::get_from_path
to remove this side effect.