Explorar el Código

IDLE crash fixed

Yurii Sokolovskyi hace 2 semanas
padre
commit
28aab97178
Se han modificado 1 ficheros con 12 adiciones y 4 borrados
  1. 12 4
      src/imap.rs

+ 12 - 4
src/imap.rs

@@ -408,13 +408,21 @@ pub fn check_for_updates(mailbox: String) -> JoinHandle<Result<(), anyhow::Error
                         _ => {}
                     }
                 }
-                reason => {
-                    println!("IDLE failed {:?}", reason);
-                }
+                _ => {}
             }
 
             // Reassign session to prevent ownership issues in the next loop iteration
-            session = idle.done().await.unwrap();
+            let mut error = false;
+            session = match idle.done().await {
+                Ok(idl) => idl,
+                Err(_) => {
+                    error = true;
+                    get_session().await?
+                }
+            };
+            if error == true{
+                session.select(mailbox.clone()).await?;
+            }
         }
     })
 }