mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-09-10 16:04:41 +00:00
Fix resync issue for empty accounts by skipping full rebuild and going straight to incremental sync
This commit is contained in:
+36
-37
@@ -26,29 +26,29 @@ pub async fn rebuild_cache(
|
||||
let use_proxy = account.use_proxy;
|
||||
OutlookFolder::batch_insert(remote_folders).await?;
|
||||
for folder in remote_folders {
|
||||
if folder.exists == 0 {
|
||||
info!(
|
||||
"Account {}: folder '{}' on the remote server has no emails. Skipping fetch for this folder.",
|
||||
account.id, &folder.name
|
||||
);
|
||||
continue;
|
||||
}
|
||||
match fetch_and_save_full_folder(account, folder, folder.exists, true).await {
|
||||
Ok(inserted) => {
|
||||
total_inserted += inserted;
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
if folder.exists > 0 {
|
||||
match fetch_and_save_full_folder(account, folder, folder.exists, true).await {
|
||||
Ok(inserted) => {
|
||||
total_inserted += inserted;
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"Account {}: Failed to sync label '{}'. Error: {:#?}. Removing label entry.",
|
||||
account.id, &folder.name, e
|
||||
);
|
||||
if let Err(del_err) = OutlookFolder::delete(folder.id).await {
|
||||
error!(
|
||||
"Account {}: Failed to delete label '{}' after sync error: {}",
|
||||
account.id, &folder.name, del_err
|
||||
);
|
||||
if let Err(del_err) = OutlookFolder::delete(folder.id).await {
|
||||
error!(
|
||||
"Account {}: Failed to delete label '{}' after sync error: {}",
|
||||
account.id, &folder.name, del_err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn!(
|
||||
"Account {}: folder '{}' on the remote server has no emails. Skipping fetch for this folder.",
|
||||
account.id, &folder.name
|
||||
);
|
||||
}
|
||||
|
||||
let delta_link =
|
||||
@@ -78,30 +78,29 @@ pub async fn rebuild_cache_since_date(
|
||||
|
||||
OutlookFolder::batch_insert(remote_folders).await?;
|
||||
for folder in remote_folders {
|
||||
if folder.exists == 0 {
|
||||
info!(
|
||||
"Account {}: Mailbox '{}' on the remote server has no emails. Skipping fetch for this mailbox.",
|
||||
account.id, &folder.name
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
match fetch_and_save_since_date(account, date.as_str(), folder, true).await {
|
||||
Ok(inserted) => {
|
||||
total_inserted += inserted;
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
if folder.exists > 0 {
|
||||
match fetch_and_save_since_date(account, date.as_str(), folder, true).await {
|
||||
Ok(inserted) => {
|
||||
total_inserted += inserted;
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"Account {}: Failed to sync mailbox '{}'. Error: {}. Removing mailbox entry.",
|
||||
account.id, &folder.name, e
|
||||
);
|
||||
if let Err(del_err) = OutlookFolder::delete(folder.id).await {
|
||||
error!(
|
||||
"Account {}: Failed to delete mailbox '{}' after sync error: {}",
|
||||
account.id, &folder.name, del_err
|
||||
);
|
||||
if let Err(del_err) = OutlookFolder::delete(folder.id).await {
|
||||
error!(
|
||||
"Account {}: Failed to delete mailbox '{}' after sync error: {}",
|
||||
account.id, &folder.name, del_err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn!(
|
||||
"Account {}: Mailbox '{}' on the remote server has no emails. Skipping fetch for this mailbox.",
|
||||
account.id, &folder.name
|
||||
);
|
||||
}
|
||||
let delta_link =
|
||||
OutlookClient::get_delta_link(account_id, use_proxy, &folder.folder_id).await?;
|
||||
|
||||
@@ -483,11 +483,9 @@ export function MailDisplayDrawer({ open, setOpen, onOpenChange, currentEnvelope
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="flex items-start">
|
||||
<div className="grid gap-1">
|
||||
<div className="line-clamp-1 text-xs space-x-2">
|
||||
<span className="font-medium text-gray-400">
|
||||
{isGmailApi ? "Mid:" : "Uid:"}
|
||||
</span>
|
||||
<span>{currentEnvelope.id}</span>
|
||||
<div className="truncate text-xs">
|
||||
<span className="font-medium text-gray-400">ID:</span>
|
||||
<span className="ml-2">{currentEnvelope.id}</span>
|
||||
</div>
|
||||
{currentEnvelope.from && (
|
||||
<div className="line-clamp-1 text-xs space-x-2">
|
||||
|
||||
@@ -67,7 +67,7 @@ export function MailList({
|
||||
<div
|
||||
key={item.id}
|
||||
className={cn(
|
||||
"group flex items-center gap-2 p-1.5 pr-2 rounded-md border transition-all cursor-pointer text-xs",
|
||||
"group flex items-center gap-2 p-1.5 pr-2 rounded-md border transition-all cursor-pointer text-sm",
|
||||
"hover:bg-accent/70",
|
||||
isActive && "bg-accent",
|
||||
isSelected && "bg-primary/10 ring-1 ring-primary/20"
|
||||
|
||||
Reference in New Issue
Block a user