Recover from 'pdf is damaged' err and update deps

This commit is contained in:
itsjunetime
2024-08-15 18:15:50 -06:00
parent f0c0e06c1c
commit 4296c92d7d
4 changed files with 108 additions and 94 deletions
+15 -1
View File
@@ -90,7 +90,21 @@ pub fn start_rendering(
'reload: loop {
let doc = match Document::from_file(&path, None) {
Err(e) => return sender.send(Err(RenderError::Doc(e))),
Err(e) => {
// if there's an error, tell the main loop
sender.send(Err(RenderError::Doc(e)))?;
// then wait for a reload notif (since what probably happened is that the file was
// temporarily removed to facilitate a save or something like that)
while let Ok(msg) = receiver.recv() {
// and once that comes, just try to reload again
if let RenderNotif::Reload = msg {
continue 'reload;
}
}
// if that while let Ok ever fails and we exit out of that loop, the main thread is
// done, so we're fine to just return
return Ok(());
}
Ok(d) => d
};