Skip to content

purge all rustwide build directories before each build #2250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,22 @@ impl RustwideBuilder {
let mut conn = self.db.get()?;
let limits = Limits::for_crate(&self.config, &mut conn, DUMMY_CRATE_NAME)?;

// FIXME: for now, purge all build dirs before each build.
// Currently we have some error situations where the build directory wouldn't be deleted
// after the build failed:
// https://github.com/rust-lang/docs.rs/issues/820
// This should be solved in a better way, likely refactoring the whole builder structure,
// but for now we chose this simple way to prevent that the build directory remains can
// fill up disk space.
// This also prevents having multiple builders using the same rustwide workspace,
// which we don't do. Currently our separate builders use a separate rustwide workspace.
self.workspace
.purge_all_build_dirs()
.map_err(FailureError::compat)?;

let mut build_dir = self
.workspace
.build_dir(&format!("essential-files-{rustc_version}"));
build_dir.purge().map_err(FailureError::compat)?;

// This is an empty library crate that is supposed to always build.
let krate = Crate::crates_io(DUMMY_CRATE_NAME, DUMMY_CRATE_VERSION);
Expand Down Expand Up @@ -288,7 +300,6 @@ impl RustwideBuilder {
})
.map_err(|e| e.compat())?;

build_dir.purge().map_err(FailureError::compat)?;
krate
.purge_from_cache(&self.workspace)
.map_err(FailureError::compat)?;
Expand Down Expand Up @@ -363,8 +374,20 @@ impl RustwideBuilder {
}
}

// FIXME: for now, purge all build dirs before each build.
// Currently we have some error situations where the build directory wouldn't be deleted
// after the build failed:
// https://github.com/rust-lang/docs.rs/issues/820
// This should be solved in a better way, likely refactoring the whole builder structure,
// but for now we chose this simple way to prevent that the build directory remains can
// fill up disk space.
// This also prevents having multiple builders using the same rustwide workspace,
// which we don't do. Currently our separate builders use a separate rustwide workspace.
self.workspace
.purge_all_build_dirs()
.map_err(FailureError::compat)?;

let mut build_dir = self.workspace.build_dir(&format!("{name}-{version}"));
build_dir.purge().map_err(FailureError::compat)?;

let is_local = matches!(kind, PackageKind::Local(_));
let krate = match kind {
Expand Down Expand Up @@ -564,7 +587,6 @@ impl RustwideBuilder {
})
.map_err(|e| e.compat())?;

build_dir.purge().map_err(FailureError::compat)?;
krate
.purge_from_cache(&self.workspace)
.map_err(FailureError::compat)?;
Expand Down