correct arithmetic adjustments
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
16a98b0683
commit
321e197d8c
12 changed files with 24 additions and 53 deletions
|
@ -25,7 +25,7 @@ impl service::rooms::state_accessor::Data for KeyValueDatabase {
|
|||
.parse_compressed_state_event(compressed)?;
|
||||
result.insert(parsed.0, parsed.1);
|
||||
|
||||
i = i.saturating_add(1);
|
||||
i = i.wrapping_add(1);
|
||||
if i % 100 == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ impl service::rooms::state_accessor::Data for KeyValueDatabase {
|
|||
);
|
||||
}
|
||||
|
||||
i = i.saturating_add(1);
|
||||
i = i.wrapping_add(1);
|
||||
if i % 100 == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
|
|
@ -284,11 +284,7 @@ fn count_to_id(room_id: &RoomId, count: PduCount, offset: u64, subtract: bool) -
|
|||
pdu_id.extend_from_slice(&0_u64.to_be_bytes());
|
||||
let num = u64::MAX.saturating_sub(x);
|
||||
if subtract {
|
||||
if num > 0 {
|
||||
num.saturating_sub(offset)
|
||||
} else {
|
||||
num
|
||||
}
|
||||
num.saturating_sub(offset)
|
||||
} else {
|
||||
num.saturating_add(offset)
|
||||
}
|
||||
|
|
|
@ -173,13 +173,11 @@ pub(crate) async fn migrations(db: &KeyValueDatabase, config: &Config) -> Result
|
|||
let mut current_sstatehash: Option<u64> = None;
|
||||
let mut current_room = None;
|
||||
let mut current_state = HashSet::new();
|
||||
let mut counter: u32 = 0;
|
||||
|
||||
let mut handle_state = |current_sstatehash: u64,
|
||||
current_room: &RoomId,
|
||||
current_state: HashSet<_>,
|
||||
last_roomstates: &mut HashMap<_, _>| {
|
||||
counter = counter.saturating_add(1);
|
||||
let handle_state = |current_sstatehash: u64,
|
||||
current_room: &RoomId,
|
||||
current_state: HashSet<_>,
|
||||
last_roomstates: &mut HashMap<_, _>| {
|
||||
let last_roomsstatehash = last_roomstates.get(current_room);
|
||||
|
||||
let states_parents = last_roomsstatehash.map_or_else(
|
||||
|
|
|
@ -402,19 +402,8 @@ impl KeyValueDatabase {
|
|||
let sqlite_exists = path.join("conduit.db").exists();
|
||||
let rocksdb_exists = path.join("IDENTITY").exists();
|
||||
|
||||
let mut count: u8 = 0;
|
||||
|
||||
if sqlite_exists {
|
||||
count = count.saturating_add(1);
|
||||
}
|
||||
|
||||
if rocksdb_exists {
|
||||
count = count.saturating_add(1);
|
||||
}
|
||||
|
||||
if count > 1 {
|
||||
error!("Multiple databases at database_path detected");
|
||||
return Ok(());
|
||||
if sqlite_exists && rocksdb_exists {
|
||||
return Err(Error::bad_config("Multiple databases at database_path detected."));
|
||||
}
|
||||
|
||||
if sqlite_exists && config.database_backend != "sqlite" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue