浏览代码

IDLE crash fixed

Yurii Sokolovskyi 2 周之前
父节点
当前提交
28aab97178
共有 1 个文件被更改,包括 12 次插入4 次删除
  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?;
+            }
         }
     })
 }