Skip to content

Commit 4d4fdc9

Browse files
committed
Check settings version on Cfg construction
1 parent 2c58dca commit 4d4fdc9

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/cli/proxy_mode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub async fn main(arg0: &str, current_dir: PathBuf, process: &Process) -> Result
3232
.collect();
3333

3434
let cfg = set_globals(current_dir, false, true, process)?;
35-
cfg.check_metadata_version()?;
3635
let cmd = cfg.local_toolchain(toolchain).await?.command(arg0)?;
3736
run_command_for_dir(cmd, arg0, &cmd_args)
3837
}

src/cli/rustup_mode.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,6 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
573573
cfg.set_toolchain_override(t);
574574
}
575575

576-
cfg.check_metadata_version()?;
577-
578576
let Some(subcmd) = matches.subcmd else {
579577
eprintln!("{}", Rustup::command().render_long_help());
580578
return Ok(utils::ExitCode(1));

src/config.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ impl<'a> Cfg<'a> {
259259
utils::ensure_dir_exists("home", &rustup_dir, notify_handler.as_ref())?;
260260

261261
let settings_file = SettingsFile::new(rustup_dir.join("settings.toml"));
262+
settings_file.with(|s| {
263+
(notify_handler)(Notification::ReadMetadataVersion(s.version));
264+
if s.version == MetadataVersion::default() {
265+
Ok(())
266+
} else {
267+
Err(anyhow!(
268+
"rustup's metadata is out of date. run `rustup self upgrade-data`"
269+
))
270+
}
271+
})?;
262272

263273
// Centralised file for multi-user systems to provide admin/distributor set initial values.
264274
let fallback_settings = if cfg!(not(windows)) {
@@ -916,22 +926,6 @@ impl<'a> Cfg<'a> {
916926
Ok(channels.collect().await)
917927
}
918928

919-
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
920-
pub(crate) fn check_metadata_version(&self) -> Result<()> {
921-
utils::assert_is_directory(&self.rustup_dir)?;
922-
923-
self.settings_file.with(|s| {
924-
(self.notify_handler)(Notification::ReadMetadataVersion(s.version));
925-
if s.version == MetadataVersion::default() {
926-
Ok(())
927-
} else {
928-
Err(anyhow!(
929-
"rustup's metadata is out of date. run `rustup self upgrade-data`"
930-
))
931-
}
932-
})
933-
}
934-
935929
pub(crate) fn set_default_host_triple(&self, host_triple: String) -> Result<()> {
936930
// Ensure that the provided host_triple is capable of resolving
937931
// against the 'stable' toolchain. This provides early errors

0 commit comments

Comments
 (0)