From 723fc596ea29cb93e65be40c57f6fd11a1f37161 Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Wed, 4 Oct 2023 17:25:56 +0200 Subject: [PATCH] add build set-toolchain subcommand --- src/bin/cratesfyi.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bin/cratesfyi.rs b/src/bin/cratesfyi.rs index 8bead0151..ea3dca362 100644 --- a/src/bin/cratesfyi.rs +++ b/src/bin/cratesfyi.rs @@ -12,7 +12,7 @@ use docs_rs::db::{self, add_path_into_database, Overrides, Pool, PoolClient}; use docs_rs::repositories::RepositoryStatsUpdater; use docs_rs::utils::{ get_config, get_crate_pattern_and_priority, list_crate_priorities, queue_builder, - remove_crate_priority, set_crate_priority, ConfigName, + remove_crate_priority, set_config, set_crate_priority, ConfigName, }; use docs_rs::{ start_background_metrics_webserver, start_web_server, BuildQueue, Config, Context, Index, @@ -383,6 +383,10 @@ enum BuildSubcommand { /// Adds essential files for the installed version of rustc AddEssentialFiles, + SetToolchain { + toolchain_name: String, + }, + /// Locks the daemon, preventing it from building new crates Lock, @@ -459,6 +463,15 @@ impl BuildSubcommand { .context("failed to add essential files")?; } + Self::SetToolchain { toolchain_name } => { + let mut conn = ctx + .pool()? + .get() + .context("failed to get a database connection")?; + set_config(&mut conn, ConfigName::Toolchain, toolchain_name) + .context("failed to set toolchain in database")?; + } + Self::Lock => build_queue.lock().context("Failed to lock")?, Self::Unlock => build_queue.unlock().context("Failed to unlock")?, }