truncate: remove read permissions from OpenOptions

Remove "read" permissions from the `OpenOptions` when opening a new file
just to truncate it. We will never read from the file, only write to
it. (Specifically, we will only call `File::set_len()`.)
This commit is contained in:
Jeffrey Finkelstein 2021-05-21 18:23:50 -04:00
parent a746e37dc7
commit 5eb2a5c3e1

View file

@ -189,12 +189,7 @@ fn truncate(
};
for filename in &filenames {
let path = Path::new(filename);
match OpenOptions::new()
.read(true)
.write(true)
.create(!no_create)
.open(path)
{
match OpenOptions::new().write(true).create(!no_create).open(path) {
Ok(file) => {
let fsize = match reference {
Some(_) => refsize,