diff --git a/src/init/sd_card.rs b/src/init/sd_card.rs index d90ce17..9fa50d8 100644 --- a/src/init/sd_card.rs +++ b/src/init/sd_card.rs @@ -42,13 +42,16 @@ impl Persistence for SDCardPersistence { async fn load_day(&mut self, day: crate::store::Date) -> Option { let mut vol_0 = self.vol_mgr.open_volume(VolumeIdx(0)).unwrap(); let mut root_dir = vol_0.open_root_dir().unwrap(); - let mut file = root_dir - .open_file_in_dir("day.jsn", embedded_sdmmc::Mode::ReadOnly) - .unwrap(); + let mut file = root_dir.open_file_in_dir("day.jsn", embedded_sdmmc::Mode::ReadOnly); + + if let Err(e) = file { + return None; + } + let mut open_file = file.unwrap(); let mut read_buffer: [u8; 1024] = [0; 1024]; - let read = file.read(&mut read_buffer).unwrap(); - file.close().unwrap(); + let read = open_file.read(&mut read_buffer).unwrap(); + open_file.close().unwrap(); let day: AttendanceDay = serde_json::from_slice(&read_buffer[..read]).unwrap(); diff --git a/src/store/id_store.rs b/src/store/id_store.rs index 979a576..d122c77 100644 --- a/src/store/id_store.rs +++ b/src/store/id_store.rs @@ -41,10 +41,10 @@ pub struct IDStore { impl IDStore { pub async fn new_from_storage(mut persistence_layer: T) -> Self { - let mapping = match persistence_layer.load_mapping().await { - Some(map) => map, - None => IDMapping::new(), - }; + // let mapping = match persistence_layer.load_mapping().await { + // Some(map) => map, + // None => IDMapping::new(), + // }; let current_date: Date = 1; @@ -55,7 +55,7 @@ impl IDStore { Self { current_day: day, - mapping, + mapping: IDMapping::new(), persistence_layer, } }