mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-22 13:10:13 +08:00
Only update env_universal self.last_read_file on success
I don't think the existing logic is correct, as the comment says, our internal state is only matched if we *actually* wrote out the file. But if we ran into an error, it doesn't match, does it?
This commit is contained in:
parent
94477f3029
commit
3f6b009870
|
@ -536,23 +536,26 @@ impl EnvUniversal {
|
||||||
fn write_to_fd(&mut self, fd: impl AsFd, path: &wstr) -> std::io::Result<usize> {
|
fn write_to_fd(&mut self, fd: impl AsFd, path: &wstr) -> std::io::Result<usize> {
|
||||||
let fd = fd.as_fd();
|
let fd = fd.as_fd();
|
||||||
let contents = Self::serialize_with_vars(&self.vars);
|
let contents = Self::serialize_with_vars(&self.vars);
|
||||||
|
|
||||||
let res = write_loop(&fd, &contents);
|
let res = write_loop(&fd, &contents);
|
||||||
|
match res.as_ref() {
|
||||||
if let Err(err) = res.as_ref() {
|
Ok(_) => {
|
||||||
let error = Errno(err.raw_os_error().unwrap());
|
// Since we just wrote out this file, it matches our internal state; pretend we read from it.
|
||||||
FLOG!(
|
self.last_read_file = file_id_for_fd(fd.as_raw_fd());
|
||||||
error,
|
}
|
||||||
wgettext_fmt!(
|
Err(err) => {
|
||||||
"Unable to write to universal variables file '%ls': %s",
|
let error = Errno(err.raw_os_error().unwrap());
|
||||||
path,
|
FLOG!(
|
||||||
error.to_string()
|
error,
|
||||||
),
|
wgettext_fmt!(
|
||||||
);
|
"Unable to write to universal variables file '%ls': %s",
|
||||||
|
path,
|
||||||
|
error.to_string()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we just wrote out this file, it matches our internal state; pretend we read from it.
|
|
||||||
self.last_read_file = file_id_for_fd(fd.as_raw_fd());
|
|
||||||
|
|
||||||
// We don't close the file.
|
// We don't close the file.
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user