Fix(sync): missing initial sync start time after enabling a previously disabled account #32

This commit is contained in:
rustmailer
2025-12-03 20:11:19 +08:00
parent 0015192b4d
commit 4b13bf14c4
3 changed files with 12 additions and 17 deletions
+9 -9
View File
@@ -69,7 +69,7 @@ impl AccountRunningState {
errors: vec![], errors: vec![],
is_initial_sync_completed: false, is_initial_sync_completed: false,
progress: None, progress: None,
initial_sync_start_time: None, initial_sync_start_time: Some(utc_now!()),
initial_sync_end_time: None, initial_sync_end_time: None,
initial_sync_failed_time: None, initial_sync_failed_time: None,
}; };
@@ -125,14 +125,14 @@ impl AccountRunningState {
.await .await
} }
pub async fn set_initial_sync_start(account_id: u64) -> BichonResult<()> { // pub async fn set_initial_sync_start(account_id: u64) -> BichonResult<()> {
Self::update_account_running_state(account_id, move |current| { // Self::update_account_running_state(account_id, move |current| {
let mut updated = current.clone(); // let mut updated = current.clone();
updated.initial_sync_start_time = Some(utc_now!()); // updated.initial_sync_start_time = Some(utc_now!());
Ok(updated) // Ok(updated)
}) // })
.await // .await
} // }
pub async fn set_initial_sync_completed(account_id: u64) -> BichonResult<()> { pub async fn set_initial_sync_completed(account_id: u64) -> BichonResult<()> {
Self::update_account_running_state(account_id, move |current| { Self::update_account_running_state(account_id, move |current| {
+2 -3
View File
@@ -16,7 +16,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::{ use crate::{
modules::{ modules::{
account::{ account::{
@@ -46,13 +45,13 @@ pub async fn execute_imap_sync(account: &AccountModel) -> BichonResult<()> {
let start_time = Instant::now(); let start_time = Instant::now();
let account_id = account.id; let account_id = account.id;
let sync_type = determine_sync_type(account).await?; let sync_type = determine_sync_type(account).await?;
if matches!(sync_type, SyncType::SkipSync) { if matches!(sync_type, SyncType::SkipSync) {
return Ok(()); return Ok(());
} }
let remote_mailboxes = get_sync_folders(account).await?; let remote_mailboxes = get_sync_folders(account).await?;
if matches!(sync_type, SyncType::InitialSync) { if matches!(sync_type, SyncType::InitialSync) {
AccountRunningState::set_initial_sync_start(account_id).await?; AccountRunningState::add(account.id).await?;
// AccountRunningState::set_initial_sync_start(account_id).await?;
let result = match &account.date_since { let result = match &account.date_since {
Some(date_since) => { Some(date_since) => {
rebuild_cache_since_date(account, &remote_mailboxes, date_since).await rebuild_cache_since_date(account, &remote_mailboxes, date_since).await
+1 -5
View File
@@ -16,7 +16,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::{ use crate::{
modules::{ modules::{
account::{migration::AccountModel, state::AccountRunningState}, account::{migration::AccountModel, state::AccountRunningState},
@@ -51,10 +50,7 @@ pub async fn determine_sync_type(account: &AccountModel) -> BichonResult<SyncTyp
SyncType::SkipSync SyncType::SkipSync
} }
} }
None => { None => SyncType::InitialSync,
AccountRunningState::add(account.id).await?;
SyncType::InitialSync
}
}) })
} }