EWS fixes
This commit is contained in:
@@ -19,7 +19,7 @@ use crate::sync::TypeCounts;
|
||||
use super::attachments::{fetch_attachments, intern_attachment};
|
||||
use super::folders::FolderPlan;
|
||||
use super::items::{
|
||||
EnumerationMode, ItemRunCtx, delete_vanished, enumerate_folder, get_items, plan_for,
|
||||
EnumerationMode, ItemRunCtx, delete_vanished, enumerate_folder, for_each_fetched_item, plan_for,
|
||||
};
|
||||
|
||||
pub fn reconcile_all(
|
||||
@@ -41,9 +41,18 @@ pub fn reconcile_all(
|
||||
Some(id) => id,
|
||||
None => continue,
|
||||
};
|
||||
if let Err(e) = reconcile_one(conn, ctx, folder_id, local_folder_id, counts) {
|
||||
ctx.logger
|
||||
.warn(&format!("calendar folder {} failed: {}", folder_id.id, e));
|
||||
if let Err(e) = reconcile_one(
|
||||
conn,
|
||||
ctx,
|
||||
folder_id,
|
||||
&folder.folder.display_name,
|
||||
local_folder_id,
|
||||
counts,
|
||||
) {
|
||||
ctx.logger.warn(&format!(
|
||||
"calendar folder {:?} failed: {}",
|
||||
folder.folder.display_name, e
|
||||
));
|
||||
counts.failed += 1;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +63,7 @@ fn reconcile_one(
|
||||
conn: &mut Connection,
|
||||
ctx: &ItemRunCtx<'_>,
|
||||
folder: &crate::exchange_ews::types::FolderId,
|
||||
folder_name: &str,
|
||||
local_folder_id: i64,
|
||||
counts: &mut TypeCounts,
|
||||
) -> Result<(), Error> {
|
||||
@@ -81,8 +91,8 @@ fn reconcile_one(
|
||||
let plan = plan_for(&outcome, &local);
|
||||
if ctx.logger.enabled(LEVEL_PROGRESS) {
|
||||
eprintln!(
|
||||
"EWS calendar folder {}: new={} changed={} vanished={}",
|
||||
folder.id,
|
||||
"EWS calendar folder {:?}: new={} changed={} vanished={}",
|
||||
folder_name,
|
||||
plan.new.len(),
|
||||
plan.present_changed.len(),
|
||||
plan.vanished.len()
|
||||
@@ -93,9 +103,7 @@ fn reconcile_one(
|
||||
to_fetch.push(id.clone());
|
||||
}
|
||||
if !to_fetch.is_empty() {
|
||||
let outcome = get_items(ctx, ItemShape::CalendarItem, &to_fetch).map_err(Error::from)?;
|
||||
counts.failed += outcome.failed_items;
|
||||
for msg in outcome.messages {
|
||||
let failed_items = for_each_fetched_item(ctx, ItemShape::CalendarItem, &to_fetch, |msg| {
|
||||
if !msg.success {
|
||||
if matches!(
|
||||
msg.response_code,
|
||||
@@ -107,19 +115,19 @@ fn reconcile_one(
|
||||
ctx.logger
|
||||
.warn(&format!("GetItem (calendar) error: {}", msg.response_code));
|
||||
}
|
||||
continue;
|
||||
return Ok(());
|
||||
}
|
||||
let parsed = parse_calendar_item(&msg.inner_xml).map_err(Error::from)?;
|
||||
if parsed.id.id.is_empty() {
|
||||
counts.failed += 1;
|
||||
continue;
|
||||
return Ok(());
|
||||
}
|
||||
if matches!(
|
||||
parsed.calendar_item_type,
|
||||
Some(CalendarItemType::Occurrence) | Some(CalendarItemType::Exception)
|
||||
) {
|
||||
counts.skipped += 1;
|
||||
continue;
|
||||
return Ok(());
|
||||
}
|
||||
let existing = plan
|
||||
.present_changed
|
||||
@@ -134,8 +142,9 @@ fn reconcile_one(
|
||||
&folder.id,
|
||||
existing,
|
||||
counts,
|
||||
)?;
|
||||
}
|
||||
)
|
||||
})?;
|
||||
counts.failed += failed_items;
|
||||
}
|
||||
delete_vanished(
|
||||
conn,
|
||||
|
||||
Reference in New Issue
Block a user