@@ -14,7 +14,6 @@ use crate::config::Config;
1414use crate :: configure:: EnteredLoginParam ;
1515use crate :: constants:: ShowEmails ;
1616use crate :: context:: Context ;
17- use crate :: imap;
1817use crate :: key:: DcKey ;
1918use crate :: log:: { info, warn} ;
2019use crate :: message:: MsgId ;
@@ -413,11 +412,36 @@ CREATE TABLE imap_sync (folder TEXT PRIMARY KEY, uidvalidity INTEGER DEFAULT 0,
413412 "configured_mvbox_folder" ,
414413 ] {
415414 if let Some ( folder) = context. sql . get_raw_config ( c) . await ? {
415+ let key = format ! ( "imap.mailbox.{folder}" ) ;
416+
416417 let ( uid_validity, last_seen_uid) =
417- imap:: get_config_last_seen_uid ( context, & folder) . await ?;
418+ if let Some ( entry) = context. sql . get_raw_config ( & key) . await ? {
419+ // the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
420+ let mut parts = entry. split ( ':' ) ;
421+ (
422+ parts. next ( ) . unwrap_or_default ( ) . parse ( ) . unwrap_or ( 0 ) ,
423+ parts. next ( ) . unwrap_or_default ( ) . parse ( ) . unwrap_or ( 0 ) ,
424+ )
425+ } else {
426+ ( 0 , 0 )
427+ } ;
418428 if last_seen_uid > 0 {
419- imap:: set_uid_next ( context, & folder, last_seen_uid + 1 ) . await ?;
420- imap:: set_uidvalidity ( context, & folder, uid_validity) . await ?;
429+ context
430+ . sql
431+ . execute (
432+ "INSERT INTO imap_sync (folder, uid_next) VALUES (?,?)
433+ ON CONFLICT(folder) DO UPDATE SET uid_next=excluded.uid_next" ,
434+ ( & folder, last_seen_uid + 1 ) ,
435+ )
436+ . await ?;
437+ context
438+ . sql
439+ . execute (
440+ "INSERT INTO imap_sync (folder, uidvalidity) VALUES (?,?)
441+ ON CONFLICT(folder) DO UPDATE SET uidvalidity=excluded.uidvalidity" ,
442+ ( & folder, uid_validity) ,
443+ )
444+ . await ?;
421445 }
422446 }
423447 }
0 commit comments