Skip to content

Commit bfa6ada

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Don't crash if trying to move directories for a target that failed
Previously, if there was a build with - a non-default target - that failed to build docs.rs would crash: ``` [DEBUG] cratesfyi::docbuilder::rustwide_builder: rename /home/cratesfyi/workspace/builds/stm32h7xx-hal-0.7.0/target/thumbv7em-none-eabihf/doc to /home/cratesfyi/workspace/builds/stm32h7xx-hal-0.7.0/target/doc 2020/09/03 20:15:49 [ERROR] cratesfyi::build_queue: Failed to build package stm32h7xx-hal-0.7.0 from queue: No such file or directory (os error 2) Backtrace: 0: failure::backtrace::internal::InternalBacktrace::new 1: <failure::backtrace::Backtrace as core::default::Default>::default 2: cratesfyi::docbuilder::rustwide_builder::RustwideBuilder::execute_build 3: rustwide::build::BuildBuilder::run 4: cratesfyi::docbuilder::rustwide_builder::RustwideBuilder::build_package 5: cratesfyi::build_queue::BuildQueue::process_next_crate 6: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once 7: cratesfyi::utils::queue_builder::queue_builder 8: std::sys_common::backtrace::__rust_begin_short_backtrace 9: core::ops::function::FnOnce::call_once{{vtable.shim}} 10: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/liballoc/boxed.rs:1076 <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/liballoc/boxed.rs:1076 std::sys::unix::thread::Thread::new::thread_start at /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/sys/unix/thread.rs:87 11: start_thread 12: __clone ``` The issue is it was trying to rename a directory that didn't exist, because the build failed. This no longer tries to rename the directory unless the build succeeded.
1 parent 6e86391 commit bfa6ada

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/docbuilder/rustwide_builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ impl RustwideBuilder {
532532
// cargo will put the output in `target/<target>/doc`.
533533
// However, if this is the default build, we don't want it there,
534534
// we want it in `target/doc`.
535-
if target != HOST_TARGET && is_default_target {
535+
// NOTE: don't rename this if the build failed, because `target/<target>/doc` won't exist.
536+
if successful && target != HOST_TARGET && is_default_target {
536537
// mv target/$target/doc target/doc
537538
let target_dir = build.host_target_dir();
538539
let old_dir = target_dir.join(target).join("doc");

0 commit comments

Comments
 (0)