Fixed warnings

This commit is contained in:
daladim 2021-03-19 00:08:16 +01:00
parent 35674a80c7
commit 70557160f2
3 changed files with 13 additions and 11 deletions

View file

@ -34,7 +34,7 @@ impl PartialCalendar for RemoteCalendar {
} }
/// Returns the items that have been last-modified after `since` /// Returns the items that have been last-modified after `since`
fn get_items_modified_since(&self, since: Option<DateTime<Utc>>, filter: Option<crate::calendar::SearchFilter>) fn get_items_modified_since(&self, _since: Option<DateTime<Utc>>, _filter: Option<crate::calendar::SearchFilter>)
-> HashMap<ItemId, &Item> -> HashMap<ItemId, &Item>
{ {
log::error!("Not implemented"); log::error!("Not implemented");
@ -48,18 +48,18 @@ impl PartialCalendar for RemoteCalendar {
} }
/// Returns a particular item /// Returns a particular item
fn get_item_by_id_mut(&mut self, id: &ItemId) -> Option<&mut Item> { fn get_item_by_id_mut(&mut self, _id: &ItemId) -> Option<&mut Item> {
log::error!("Not implemented"); log::error!("Not implemented");
None None
} }
/// Add an item into this calendar /// Add an item into this calendar
fn add_item(&mut self, item: Item) { fn add_item(&mut self, _item: Item) {
log::error!("Not implemented"); log::error!("Not implemented");
} }
/// Remove an item from this calendar /// Remove an item from this calendar
fn delete_item(&mut self, item_id: &ItemId) -> Result<(), Box<dyn Error>> { fn delete_item(&mut self, _item_id: &ItemId) -> Result<(), Box<dyn Error>> {
log::error!("Not implemented"); log::error!("Not implemented");
Ok(()) Ok(())
} }

View file

@ -1,7 +1,7 @@
//! This modules abstracts data sources and merges them in a single virtual one //! This modules abstracts data sources and merges them in a single virtual one
use std::error::Error; use std::error::Error;
use std::collections::{HashSet, HashMap}; use std::collections::HashSet;
use std::marker::PhantomData; use std::marker::PhantomData;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
@ -65,7 +65,7 @@ where
log::info!("Starting a sync. Last sync was at {:?}", last_sync); log::info!("Starting a sync. Last sync was at {:?}", last_sync);
let cals_server = self.server.get_calendars().await?; let cals_server = self.server.get_calendars().await?;
for (id, mut cal_server) in cals_server { for (id, cal_server) in cals_server {
let mut cal_server = cal_server.lock().unwrap(); let mut cal_server = cal_server.lock().unwrap();
let cal_local = match self.local.get_calendar(id).await { let cal_local = match self.local.get_calendar(id).await {
@ -146,6 +146,8 @@ fn move_to_calendar<C: PartialCalendar>(items: &mut Vec<Item>, calendar: &mut C)
fn remove_from_calendar<C: PartialCalendar>(ids: &Vec<ItemId>, calendar: &mut C) { fn remove_from_calendar<C: PartialCalendar>(ids: &Vec<ItemId>, calendar: &mut C) {
for id in ids { for id in ids {
log::info!(" Removing {:?} from local calendar", id); log::info!(" Removing {:?} from local calendar", id);
calendar.delete_item(id); if let Err(err) = calendar.delete_item(id) {
log::warn!("Unable to delete item {:?} from calendar: {}", id, err);
}
} }
} }

View file

@ -104,7 +104,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
let cal_server = server.get_calendar(cal_id.clone()).await.unwrap(); let cal_server = server.get_calendar(cal_id.clone()).await.unwrap();
let mut cal_server = cal_server.lock().unwrap(); let mut cal_server = cal_server.lock().unwrap();
cal_server.delete_item(&task_b_id); cal_server.delete_item(&task_b_id).unwrap();
cal_server.get_item_by_id_mut(&task_e_id).unwrap().unwrap_task_mut() cal_server.get_item_by_id_mut(&task_e_id).unwrap().unwrap_task_mut()
.set_name("E has been remotely renamed".into()); .set_name("E has been remotely renamed".into());
@ -118,7 +118,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
cal_server.get_item_by_id_mut(&task_i_id).unwrap().unwrap_task_mut() cal_server.get_item_by_id_mut(&task_i_id).unwrap().unwrap_task_mut()
.set_name("I renamed in the server".into()); .set_name("I renamed in the server".into());
cal_server.delete_item(&task_j_id); cal_server.delete_item(&task_j_id).unwrap();
cal_server.get_item_by_id_mut(&task_k_id).unwrap().unwrap_task_mut() cal_server.get_item_by_id_mut(&task_k_id).unwrap().unwrap_task_mut()
.set_completed(true); .set_completed(true);
@ -132,7 +132,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
let cal_local = local.get_calendar(cal_id).await.unwrap(); let cal_local = local.get_calendar(cal_id).await.unwrap();
let mut cal_local = cal_local.lock().unwrap(); let mut cal_local = cal_local.lock().unwrap();
cal_local.delete_item(&task_c_id); cal_local.delete_item(&task_c_id).unwrap();
cal_local.get_item_by_id_mut(&task_d_id).unwrap().unwrap_task_mut() cal_local.get_item_by_id_mut(&task_d_id).unwrap().unwrap_task_mut()
.set_name("D has been locally renamed".into()); .set_name("D has been locally renamed".into());
@ -149,7 +149,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
cal_local.get_item_by_id_mut(&task_j_id).unwrap().unwrap_task_mut() cal_local.get_item_by_id_mut(&task_j_id).unwrap().unwrap_task_mut()
.set_completed(true); .set_completed(true);
cal_local.delete_item(&task_k_id); cal_local.delete_item(&task_k_id).unwrap();
let task_o = Item::Task(Task::new("task O (new from local)".into(), Utc::now())); let task_o = Item::Task(Task::new("task O (new from local)".into(), Utc::now()));
cal_local.add_item(task_o); cal_local.add_item(task_o);