Skip to content

Commit 977a94f

Browse files
Arthur Perrotclaude
andcommitted
fixup(ews): drop unused Context import + dead summary_view, collapse
duplicate connection-check arms, rustfmt Cargo.lock is updated by Cargo's first compile after a fresh dependency add (async-trait); committing it so a clean checkout doesn't churn it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 637c86c commit 977a94f

8 files changed

Lines changed: 26 additions & 48 deletions

File tree

src/commands/source.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ pub async fn run(pool: &SqlitePool, key: &[u8; 32], cmd: SourceCommands) -> Resu
101101
} => {
102102
let provider = provider.trim().to_ascii_lowercase();
103103
if provider != factory::kinds::CALDAV && provider != factory::kinds::EWS {
104-
bail!(
105-
"unknown provider '{}'. Use 'caldav' or 'ews'.",
106-
provider
107-
);
104+
bail!("unknown provider '{}'. Use 'caldav' or 'ews'.", provider);
108105
}
109106

110107
let account: (String,) = sqlx::query_as("SELECT id FROM accounts LIMIT 1")
@@ -125,7 +122,10 @@ pub async fn run(pool: &SqlitePool, key: &[u8; 32], cmd: SourceCommands) -> Resu
125122
let email_for_disco = email
126123
.clone()
127124
.unwrap_or_else(|| prompt("Email (for Autodiscover)"));
128-
print!("{} Discovering EWS endpoint via Autodiscover… ", "…".dimmed());
125+
print!(
126+
"{} Discovering EWS endpoint via Autodiscover… ",
127+
"…".dimmed()
128+
);
129129
io::stdout().flush().ok();
130130
match crate::ews::autodiscover::discover_ews_url(
131131
&email_for_disco,

src/ews/ical.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ pub fn synth_vcalendar(item: &EwsCalendarItem) -> Option<String> {
7676
fn format_dt(value: &str, all_day: bool) -> String {
7777
if all_day {
7878
// All-day events use VALUE=DATE with YYYYMMDD.
79-
let date = value
80-
.chars()
81-
.take(10)
82-
.collect::<String>()
83-
.replace('-', "");
79+
let date = value.chars().take(10).collect::<String>().replace('-', "");
8480
return format!(";VALUE=DATE:{}", date);
8581
}
8682
// EWS UTC is YYYY-MM-DDTHH:MM:SSZ → iCal UTC YYYYMMDDTHHMMSSZ.

src/ews/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ impl CalendarProvider for EwsProvider {
119119
Ok(synth_or_fetch_mime(self, items).await)
120120
}
121121

122-
async fn sync_delta(
123-
&self,
124-
calendar_id: &str,
125-
sync_state: Option<&str>,
126-
) -> Result<DeltaResult> {
122+
async fn sync_delta(&self, calendar_id: &str, sync_state: Option<&str>) -> Result<DeltaResult> {
127123
// Cursor-seeding mode (see trait docs): the caller has already
128124
// populated the local cache via `fetch_events` and only wants a
129125
// starting cursor. EWS's `SyncFolderItems` without a state walks
@@ -196,13 +192,9 @@ impl CalendarProvider for EwsProvider {
196192
.await
197193
.unwrap_or_default();
198194
for item_id in &existing {
199-
if let Err(e) = operations::delete_item(
200-
&self.endpoint,
201-
&self.username,
202-
&self.password,
203-
item_id,
204-
)
205-
.await
195+
if let Err(e) =
196+
operations::delete_item(&self.endpoint, &self.username, &self.password, item_id)
197+
.await
206198
{
207199
tracing::warn!(uid = %uid, error = %e, "EWS could not delete prior copy before re-create; continuing");
208200
}

src/ews/operations.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ pub async fn check_connection(endpoint: &str, username: &str, password: &str) ->
2929
</m:GetFolder>
3030
"#;
3131
let resp = post_soap(endpoint, username, password, body, false).await?;
32-
if resp.contains("FolderId") {
33-
Ok(true)
34-
} else if resp.contains("ResponseClass=\"Success\"") {
32+
// post_soap already raises on SOAP faults; we only need to confirm the
33+
// response carries a real folder reference (or, as a softer fallback, the
34+
// standard Success class) before declaring the endpoint EWS-compatible.
35+
if resp.contains("FolderId") || resp.contains("ResponseClass=\"Success\"") {
3536
Ok(true)
3637
} else {
37-
// post_soap already raises on faults; this branch only hits when the
38-
// server replied 200 but with an unexpected body shape.
3938
bail!("EWS GetFolder returned no FolderId — server may not be EWS-compatible")
4039
}
4140
}
@@ -119,7 +118,6 @@ async fn list_items_window(
119118
) -> Result<Vec<EwsCalendarItem>> {
120119
let mut all = Vec::new();
121120
let mut offset: u32 = 0;
122-
let mut summary_view = String::new();
123121
loop {
124122
let view = if let (Some(s), Some(e)) = (start_utc, end_utc) {
125123
// CalendarView expands recurrences; no offset paging is needed
@@ -134,7 +132,6 @@ async fn list_items_window(
134132
r#"<m:IndexedPageItemView MaxEntriesReturned="{PAGE_SIZE}" Offset="{offset}" BasePoint="Beginning" />"#,
135133
)
136134
};
137-
summary_view = view.clone();
138135

139136
let body = format!(
140137
r#" <m:FindItem Traversal="Shallow">
@@ -183,7 +180,7 @@ async fn list_items_window(
183180
break;
184181
}
185182
}
186-
tracing::debug!(folder = %folder_id, count = all.len(), view = %summary_view, "EWS FindItem complete");
183+
tracing::debug!(folder = %folder_id, count = all.len(), "EWS FindItem complete");
187184
Ok(all)
188185
}
189186

src/ews/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! consistent enough that targeted extraction is reliable, and the test
77
//! suite (alongside `cargo clippy`) catches regressions.
88
9-
use anyhow::{bail, Context, Result};
9+
use anyhow::{bail, Result};
1010
use base64::Engine;
1111

1212
use super::soap::{attr, collect_blocks, collect_tag_contents, first_tag_content};

src/ews/soap.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ pub async fn post_soap(
7272
body: &str,
7373
fetch: bool,
7474
) -> Result<String> {
75-
let timeout = if fetch { FETCH_TIMEOUT } else { DEFAULT_TIMEOUT };
75+
let timeout = if fetch {
76+
FETCH_TIMEOUT
77+
} else {
78+
DEFAULT_TIMEOUT
79+
};
7680
let client = http_client(timeout)?;
7781
let envelope = envelope(body);
7882

@@ -114,8 +118,8 @@ pub fn extract_soap_fault(xml: &str) -> Option<String> {
114118
return None;
115119
}
116120
// Errors come either as a SOAP Fault or as a per-message ResponseCode.
117-
if let Some(reason) = first_tag_content(xml, "faultstring")
118-
.or_else(|| first_tag_content(xml, "Reason"))
121+
if let Some(reason) =
122+
first_tag_content(xml, "faultstring").or_else(|| first_tag_content(xml, "Reason"))
119123
{
120124
return Some(reason);
121125
}
@@ -337,10 +341,7 @@ mod tests {
337341
#[test]
338342
fn fault_detection() {
339343
let xml = "<soap:Fault><faultstring>auth required</faultstring></soap:Fault>";
340-
assert_eq!(
341-
extract_soap_fault(xml),
342-
Some("auth required".to_string())
343-
);
344+
assert_eq!(extract_soap_fault(xml), Some("auth required".to_string()));
344345
}
345346

346347
#[test]

src/providers/caldav.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ impl CalendarProvider for CaldavProvider {
7878
.collect())
7979
}
8080

81-
async fn sync_delta(
82-
&self,
83-
calendar_id: &str,
84-
sync_state: Option<&str>,
85-
) -> Result<DeltaResult> {
81+
async fn sync_delta(&self, calendar_id: &str, sync_state: Option<&str>) -> Result<DeltaResult> {
8682
let result = self.client.sync_collection(calendar_id, sync_state).await?;
8783
// CalDAV reports deletions as 404 hrefs. The href ends with `{uid}.ics`,
8884
// so we extract the UID — the rest of calrs keys events by UID.

src/providers/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ pub trait CalendarProvider: Send + Sync {
8888
/// items. Implementations may therefore return an empty
8989
/// `added_or_changed` when `sync_state` is `None` — the caller has
9090
/// already populated the local cache through `fetch_events`.
91-
async fn sync_delta(
92-
&self,
93-
calendar_id: &str,
94-
sync_state: Option<&str>,
95-
) -> Result<DeltaResult>;
91+
async fn sync_delta(&self, calendar_id: &str, sync_state: Option<&str>) -> Result<DeltaResult>;
9692

9793
/// Create-or-replace an event. `uid` is the iCalendar UID, `ics` is the
9894
/// full VCALENDAR/VEVENT block.

0 commit comments

Comments
 (0)