Fix panic when starting helix tutor (#11352)

Closes #11351

Also fixed some minor issues related to log
message contents, and removed unnecessary use
of `.as_mut()` as per code review comments on
the PR.
pull/11358/head
dnaq 4 months ago committed by GitHub
parent fade4b218c
commit f5950196d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1080,22 +1080,25 @@ impl Document {
} }
pub fn pickup_last_saved_time(&mut self) { pub fn pickup_last_saved_time(&mut self) {
self.last_saved_time = match self.path.as_mut().unwrap().metadata() { self.last_saved_time = match self.path().as_mut() {
Ok(metadata) => match metadata.modified() { Some(path) => match path.metadata() {
Ok(mtime) => mtime, Ok(metadata) => match metadata.modified() {
Err(_) => { Ok(mtime) => mtime,
Err(_) => {
log::error!(
"Use a system time instead of fs' mtime not supported on this platform"
);
SystemTime::now()
}
},
Err(e) => {
log::error!( log::error!(
"Use a system time instead of fs' mtime not supported on this platform" "Use a system time instead of fs' mtime: failed to file's metadata: {e}"
); );
SystemTime::now() SystemTime::now()
} }
}, },
Err(e) => { None => SystemTime::now(),
log::error!(
"Use a system time instead of fs' mtime: failed to file's metadata: {e}"
);
SystemTime::now()
}
}; };
} }

Loading…
Cancel
Save