mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Wrap updates in transaction
This commit is contained in:
parent
49e2fb80e7
commit
6b70354fbb
@ -21,9 +21,15 @@ fn update(character_id: i32, stats: &StatsUpdate, connection: &SqliteConnection)
|
||||
|
||||
fn batch_update(updates: impl Iterator<Item = (i32, StatsUpdate)>, db_dir: &str) {
|
||||
let connection = establish_connection(db_dir);
|
||||
if let Err(err) = connection.transaction::<_, diesel::result::Error, _>(|| {
|
||||
updates.for_each(|(character_id, stats_update)| {
|
||||
update(character_id, &stats_update, &connection)
|
||||
});
|
||||
|
||||
updates
|
||||
.for_each(|(character_id, stats_update)| update(character_id, &stats_update, &connection));
|
||||
Ok(())
|
||||
}) {
|
||||
log::error!("Error during stats batch update transaction: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Updater {
|
||||
|
Loading…
Reference in New Issue
Block a user