Browse Source

make inmemorytransaction actually work

pull/113/head
jake 3 years ago
parent
commit
e407409f04
  1. 45
      src/entity/gateway/inmemory.rs

45
src/entity/gateway/inmemory.rs

@ -21,18 +21,39 @@ impl<'a> EntityGatewayTransaction for InMemoryGatewayTransaction<'a> {
&mut self.working_gateway &mut self.working_gateway
} }
async fn commit(self: Box<Self>) -> Result<(), GatewayError> {
self.original_gateway.users = self.working_gateway.users.clone();
self.original_gateway.user_settings = self.working_gateway.user_settings.clone();
self.original_gateway.characters = self.working_gateway.characters.clone();
self.original_gateway.character_meseta = self.working_gateway.character_meseta.clone();
self.original_gateway.bank_meseta = self.working_gateway.bank_meseta.clone();
self.original_gateway.items = self.working_gateway.items.clone();
self.original_gateway.inventories = self.working_gateway.inventories.clone();
self.original_gateway.banks = self.working_gateway.banks.clone();
self.original_gateway.equips = self.working_gateway.equips.clone();
self.original_gateway.mag_modifiers = self.working_gateway.mag_modifiers.clone();
self.original_gateway.weapon_modifiers = self.working_gateway.weapon_modifiers.clone();
async fn commit(mut self: Box<Self>) -> Result<(), GatewayError> {
self.original_gateway.users.lock().unwrap().clear();
self.original_gateway.users.lock().unwrap().extend(self.working_gateway.users.lock().unwrap().clone());
self.original_gateway.user_settings.lock().unwrap().clear();
self.original_gateway.user_settings.lock().unwrap().extend(self.working_gateway.user_settings.lock().unwrap().clone());
self.original_gateway.characters.lock().unwrap().clear();
self.original_gateway.characters.lock().unwrap().extend(self.working_gateway.characters.lock().unwrap().clone());
self.original_gateway.character_meseta.lock().unwrap().clear();
self.original_gateway.character_meseta.lock().unwrap().extend(self.working_gateway.character_meseta.lock().unwrap().clone());
self.original_gateway.bank_meseta.lock().unwrap().clear();
self.original_gateway.bank_meseta.lock().unwrap().extend(self.working_gateway.bank_meseta.lock().unwrap().clone());
self.original_gateway.items.lock().unwrap().clear();
self.original_gateway.items.lock().unwrap().extend(self.working_gateway.items.lock().unwrap().clone());
self.original_gateway.inventories.lock().unwrap().clear();
self.original_gateway.inventories.lock().unwrap().extend(self.working_gateway.inventories.lock().unwrap().clone());
self.original_gateway.banks.lock().unwrap().clear();
self.original_gateway.banks.lock().unwrap().extend(self.working_gateway.banks.lock().unwrap().clone());
self.original_gateway.equips.lock().unwrap().clear();
self.original_gateway.equips.lock().unwrap().extend(self.working_gateway.equips.lock().unwrap().clone());
self.original_gateway.mag_modifiers.lock().unwrap().clear();
self.original_gateway.mag_modifiers.lock().unwrap().extend(self.working_gateway.mag_modifiers.lock().unwrap().clone());
self.original_gateway.weapon_modifiers.lock().unwrap().clear();
self.original_gateway.weapon_modifiers.lock().unwrap().extend(self.working_gateway.weapon_modifiers.lock().unwrap().clone());
Ok(()) Ok(())
} }

Loading…
Cancel
Save