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