@@ -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
@@ -526,28 +526,19 @@ impl GlobalContext {
526
526
527
527
/// Which package sources have been updated, used to ensure it is only done once.
528
528
pub fn updated_sources ( & self ) -> MutexGuard < ' _ , HashSet < SourceId > > {
529
- self . updated_sources
530
- . get_or_init ( || Default :: default ( ) )
531
- . lock ( )
532
- . unwrap ( )
529
+ self . updated_sources . lock ( ) . unwrap ( )
533
530
}
534
531
535
532
/// Cached credentials from credential providers or configuration.
536
533
pub fn credential_cache ( & self ) -> MutexGuard < ' _ , HashMap < CanonicalUrl , CredentialCacheValue > > {
537
- self . credential_cache
538
- . get_or_init ( || Default :: default ( ) )
539
- . lock ( )
540
- . unwrap ( )
534
+ self . credential_cache . lock ( ) . unwrap ( )
541
535
}
542
536
543
537
/// Cache of already parsed registries from the `[registries]` table.
544
538
pub ( crate ) fn registry_config (
545
539
& self ,
546
540
) -> MutexGuard < ' _ , HashMap < SourceId , Option < RegistryConfig > > > {
547
- self . registry_config
548
- . get_or_init ( || Default :: default ( ) )
549
- . lock ( )
550
- . unwrap ( )
541
+ self . registry_config . lock ( ) . unwrap ( )
551
542
}
552
543
553
544
/// Gets all config values from disk.
0 commit comments