/// Load store from disk or create cache
Load store from disk or create cache
Load store from disk or create cache
fn load_store(&self) -> Result<()> {
        debug!("Loading store from disk...");
        let store_file = OpenOptions::new().read(true)
                                           .write(true)
                                           .create(true)
                                           .open(STORE_PATH)?;
        let reader = BufReader::new(store_file);
        let mut deflate_reader = DeflateDecoder::new(reader);
        let store_result = deserialize_from(&mut deflate_reader);
        if let Err(error) = store_result {
            info!("No orders loaded from disk: {:?}", error);
        } else {
            let mut lock = self.0.write();
            let orders: FnvHashMap<OrderID, StoreObject> = store_result?;
            info!("Loaded {} orders from disk.", orders.len());
            info!("Creating indices...");
            for (id, store_object) in &orders {
                add_to_indices(&mut lock, *id, store_object.type_id, store_object.region_id);
            }
            lock.orders = orders;
            info!("Done creating indices.");
        }
        Ok(())
    }
fn load_store ( & self ) -> Result < ( ) > { debug ! ( " " ) ; let store_file = OpenOptions :: new ( ) . read ( true ) . write ( true ) . create ( true ) . open ( STORE_PATH ) ? ; let reader = BufReader :: new ( store_file ) ; let mut deflate_reader = DeflateDecoder :: new ( reader ) ; let store_result = deserialize_from ( & mut deflate_reader ) ; if let Err ( error ) = store_result { info ! ( " " error ) ; } else { let mut lock = self . 0 . write ( ) ; let orders : FnvHashMap < OrderID , StoreObject > = store_result ? ; info ! ( " " orders len ( ) ) ; info ! ( " " ) ; for ( id , store_object ) in & orders { add_to_indices ( & mut lock , * id , store_object . type_id , store_object . region_id ) ; } lock . orders = orders ; info ! ( " " ) ; } Ok ( ( ) ) }
Load store from disk or create cache
Load store from disk or create cache
&self