Skip to content

Commit 1de587d

Browse files
authored
Merge pull request #518 from jyn514/first-run
install nightly before checking what version it is
2 parents 43323cc + a7f515b commit 1de587d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ if ! [ -d "${CRATESFYI_PREFIX}/crates.io-index/.git" ]; then
3636
git --git-dir="$CRATESFYI_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
3737
fi
3838

39-
cratesfyi build add-essential-files --only-first-time
39+
cratesfyi build update-toolchain --only-first-time
4040

4141
cratesfyi "$@"

src/bin/cratesfyi.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ pub fn main() {
6565
.takes_value(true)
6666
.conflicts_with_all(&["CRATE_NAME", "CRATE_VERSION"])
6767
.help("Build a crate at a specific path")))
68-
.subcommand(SubCommand::with_name("add-essential-files")
69-
.about("Adds essential files for rustc")
68+
.subcommand(SubCommand::with_name("update-toolchain")
69+
.about("update the curretntly installed rustup toolchain")
7070
.arg(Arg::with_name("ONLY_FIRST_TIME")
7171
.long("only-first-time")
72-
.help("add essential files only if no essential files are present")))
72+
.help("update toolchain only if no toolchain is currently installed")))
73+
.subcommand(SubCommand::with_name("add-essential-files")
74+
.about("Adds essential files for the installed version of rustc"))
7375
.subcommand(SubCommand::with_name("lock").about("Locks cratesfyi daemon to stop \
7476
building new crates"))
7577
.subcommand(SubCommand::with_name("unlock")
@@ -171,16 +173,18 @@ pub fn main() {
171173
matches.value_of("CRATE_NAME").unwrap(), matches.value_of("CRATE_VERSION").unwrap(), None),
172174
}.expect("Building documentation failed");
173175
docbuilder.save_cache().expect("Failed to save cache");
174-
} else if let Some(m) = matches.subcommand_matches("add-essential-files") {
176+
} else if let Some(m) = matches.subcommand_matches("update-toolchain") {
175177
if m.is_present("ONLY_FIRST_TIME") {
176178
let conn = db::connect_db().unwrap();
177179
let res = conn.query("SELECT * FROM config WHERE name = 'rustc_version';", &[]).unwrap();
178180
if !res.is_empty() {
179-
println!("add-essential files was already called in the past, exiting");
181+
println!("update-toolchain was already called in the past, exiting");
180182
return;
181183
}
182184
}
183-
185+
let mut builder = RustwideBuilder::init().unwrap();
186+
builder.update_toolchain().expect("failed to update toolchain");
187+
} else if matches.subcommand_matches("add-essential-files").is_some() {
184188
let mut builder = RustwideBuilder::init().unwrap();
185189
builder.add_essential_files().expect("failed to add essential files");
186190
} else if let Some(_) = matches.subcommand_matches("lock") {

src/docbuilder/rustwide_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl RustwideBuilder {
9393
})
9494
}
9595

96-
fn update_toolchain(&mut self) -> Result<()> {
96+
pub fn update_toolchain(&mut self) -> Result<()> {
9797
// Ignore errors if detection fails.
9898
let old_version = self.detect_rustc_version().ok();
9999

0 commit comments

Comments
 (0)