@@ -212,12 +212,12 @@ pub struct GlobalContext {
212
212
/// Environment variable snapshot.
213
213
env : Env ,
214
214
/// Tracks which sources have been updated to avoid multiple updates.
215
- updated_sources : OnceLock < Mutex < HashSet < SourceId > > > ,
215
+ updated_sources : Mutex < HashSet < SourceId > > ,
216
216
/// Cache of credentials from configuration or credential providers.
217
217
/// Maps from url to credential value.
218
- credential_cache : OnceLock < Mutex < HashMap < CanonicalUrl , CredentialCacheValue > > > ,
218
+ credential_cache : Mutex < HashMap < CanonicalUrl , CredentialCacheValue > > ,
219
219
/// Cache of registry config from the `[registries]` table.
220
- registry_config : OnceLock < Mutex < HashMap < SourceId , Option < RegistryConfig > > > > ,
220
+ registry_config : Mutex < HashMap < SourceId , Option < RegistryConfig > > > ,
221
221
/// Locks on the package and index caches.
222
222
package_cache_lock : CacheLocker ,
223
223
/// Cached configuration parsed by Cargo
@@ -515,28 +515,19 @@ impl GlobalContext {
515
515
516
516
/// Which package sources have been updated, used to ensure it is only done once.
517
517
pub fn updated_sources ( & self ) -> MutexGuard < ' _ , HashSet < SourceId > > {
518
- self . updated_sources
519
- . get_or_init ( || Default :: default ( ) )
520
- . lock ( )
521
- . unwrap ( )
518
+ self . updated_sources . lock ( ) . unwrap ( )
522
519
}
523
520
524
521
/// Cached credentials from credential providers or configuration.
525
522
pub fn credential_cache ( & self ) -> MutexGuard < ' _ , HashMap < CanonicalUrl , CredentialCacheValue > > {
526
- self . credential_cache
527
- . get_or_init ( || Default :: default ( ) )
528
- . lock ( )
529
- . unwrap ( )
523
+ self . credential_cache . lock ( ) . unwrap ( )
530
524
}
531
525
532
526
/// Cache of already parsed registries from the `[registries]` table.
533
527
pub ( crate ) fn registry_config (
534
528
& self ,
535
529
) -> MutexGuard < ' _ , HashMap < SourceId , Option < RegistryConfig > > > {
536
- self . registry_config
537
- . get_or_init ( || Default :: default ( ) )
538
- . lock ( )
539
- . unwrap ( )
530
+ self . registry_config . lock ( ) . unwrap ( )
540
531
}
541
532
542
533
/// Gets all config values from disk.
0 commit comments