Fix lints & format
This commit is contained in:
parent
6d40097bcd
commit
792f57dc7e
36 changed files with 555 additions and 1900 deletions
|
|
@ -118,7 +118,7 @@ impl Cursors {
|
|||
};
|
||||
|
||||
self.broadcasts.send_document_update(
|
||||
vault_id.clone(),
|
||||
vault_id,
|
||||
WebSocketServerMessageWithOrigin::new(WebSocketServerMessage::CursorPositions(
|
||||
CursorPositionFromServer {
|
||||
clients: client_cursors,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ use super::websocket::{
|
|||
use crate::config::database_config::DatabaseConfig;
|
||||
use crate::consts::IDLE_POOL_TIMEOUT;
|
||||
|
||||
fn duration_millis_u64(duration: Duration) -> u64 {
|
||||
u64::try_from(duration.as_millis()).unwrap_or(u64::MAX)
|
||||
}
|
||||
|
||||
/// Holds separate reader and writer pools for a single vault.
|
||||
/// The writer pool has exactly 1 connection so writes never compete
|
||||
/// with reads for pool slots.
|
||||
|
|
@ -182,7 +186,7 @@ fn rollback_before_acquire(
|
|||
|
||||
impl Database {
|
||||
fn now_ms(&self) -> u64 {
|
||||
self.epoch.elapsed().as_millis() as u64
|
||||
duration_millis_u64(self.epoch.elapsed())
|
||||
}
|
||||
|
||||
pub async fn try_new(
|
||||
|
|
@ -817,8 +821,7 @@ impl Database {
|
|||
} else {
|
||||
WebSocketServerMessageWithOrigin::with_origin(version.device_id.clone(), envelope)
|
||||
};
|
||||
self.broadcasts
|
||||
.send_document_update(vault_id.clone(), with_origin);
|
||||
self.broadcasts.send_document_update(vault_id, with_origin);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -831,7 +834,7 @@ impl Database {
|
|||
let idle_pools: Vec<(VaultId, Arc<VaultPool>)> = {
|
||||
let mut pools = self.connection_pools.lock().await;
|
||||
let now_ms = self.now_ms();
|
||||
let idle_threshold_ms = IDLE_POOL_TIMEOUT.as_millis() as u64;
|
||||
let idle_threshold_ms = duration_millis_u64(IDLE_POOL_TIMEOUT);
|
||||
|
||||
let vaults_to_remove: Vec<VaultId> = pools
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ pub struct DocumentVersion {
|
|||
pub device_id: DeviceId,
|
||||
}
|
||||
|
||||
|
||||
impl From<StoredDocumentVersion> for DocumentVersion {
|
||||
fn from(value: StoredDocumentVersion) -> Self {
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
},
|
||||
config::user_config::User,
|
||||
errors::{SyncServerError, client_error, server_error, unauthenticated_error},
|
||||
server::auth::auth,
|
||||
server::auth::authenticate_for_vault,
|
||||
};
|
||||
|
||||
pub struct AuthenticatedWebSocketHandshake {
|
||||
|
|
@ -30,7 +30,7 @@ pub fn get_authenticated_handshake(
|
|||
|
||||
match message {
|
||||
WebSocketClientMessage::Handshake(handshake) => {
|
||||
let user = auth(state, handshake.token.trim(), vault_id)?;
|
||||
let user = authenticate_for_vault(state, handshake.token.trim(), vault_id)?;
|
||||
Ok(AuthenticatedWebSocketHandshake { handshake, user })
|
||||
}
|
||||
WebSocketClientMessage::CursorPositions(_) => Err(unauthenticated_error(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue