1616//! This module does not implement any of the safety checks that should be run
1717//! *before* the migration.
1818
19- use std:: { collections :: HashMap , pin:: pin, time:: Instant } ;
19+ use std:: { pin:: pin, time:: Instant } ;
2020
2121use chrono:: { DateTime , Utc } ;
2222use compact_str:: CompactString ;
@@ -41,7 +41,7 @@ use crate::{
4141 self , ExtractLocalpartError , FullUserId , SynapseAccessToken , SynapseDevice ,
4242 SynapseExternalId , SynapseRefreshableTokenPair , SynapseThreepid , SynapseUser ,
4343 } ,
44- SynapseReader ,
44+ HashMap , RandomState , SynapseReader ,
4545} ;
4646
4747#[ derive( Debug , Error , ContextInto ) ]
@@ -114,7 +114,7 @@ struct MigrationState {
114114
115115 /// A mapping of Synapse external ID providers to MAS upstream OAuth 2.0
116116 /// provider ID
117- provider_id_mapping : HashMap < String , Uuid > ,
117+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
118118}
119119
120120/// Performs a migration from Synapse's database to MAS' database.
@@ -137,7 +137,7 @@ pub async fn migrate(
137137 server_name : String ,
138138 clock : & dyn Clock ,
139139 rng : & mut impl RngCore ,
140- provider_id_mapping : HashMap < String , Uuid > ,
140+ provider_id_mapping : std :: collections :: HashMap < String , Uuid > ,
141141) -> Result < ( ) , Error > {
142142 let span = Span :: current ( ) ;
143143 span. pb_set_message ( "counting work" ) ;
@@ -148,8 +148,11 @@ pub async fn migrate(
148148 server_name,
149149 // We oversize the hashmaps, as the estimates are innaccurate, and we would like to avoid
150150 // reallocations.
151- users : HashMap :: with_capacity ( counts. users * 9 / 8 ) ,
152- devices_to_compat_sessions : HashMap :: with_capacity ( counts. devices * 9 / 8 ) ,
151+ users : HashMap :: with_capacity_and_hasher ( counts. users * 9 / 8 , RandomState :: default ( ) ) ,
152+ devices_to_compat_sessions : HashMap :: with_capacity_and_hasher (
153+ counts. devices * 9 / 8 ,
154+ RandomState :: default ( ) ,
155+ ) ,
153156 provider_id_mapping,
154157 } ;
155158
0 commit comments