@@ -230,10 +230,22 @@ impl RustwideBuilder {
230230 let mut conn = self.db.get()?;
231231 let limits = Limits::for_crate(&self.config, &mut conn, DUMMY_CRATE_NAME)?;
232232
233+ // FIXME: for now, purge all build dirs before each build.
234+ // Currently we have some error situations where the build directory wouldn't be deleted
235+ // after the build failed:
236+ // https://github.com/rust-lang/docs.rs/issues/820
237+ // This should be solved in a better way, likely refactoring the whole builder structure,
238+ // but for now we chose this simple way to prevent that the build directory remains can
239+ // fill up disk space.
240+ // This also prevents having multiple builders using the same rustwide workspace,
241+ // which we don't do. Currently our separate builders use a separate rustwide workspace.
242+ self.workspace
243+ .purge_all_build_dirs()
244+ .map_err(FailureError::compat)?;
245+
233246 let mut build_dir = self
234247 .workspace
235248 .build_dir(&format!("essential-files-{rustc_version}"));
236- build_dir.purge().map_err(FailureError::compat)?;
237249
238250 // This is an empty library crate that is supposed to always build.
239251 let krate = Crate::crates_io(DUMMY_CRATE_NAME, DUMMY_CRATE_VERSION);
@@ -288,7 +300,6 @@ impl RustwideBuilder {
288300 })
289301 .map_err(|e| e.compat())?;
290302
291- build_dir.purge().map_err(FailureError::compat)?;
292303 krate
293304 .purge_from_cache(&self.workspace)
294305 .map_err(FailureError::compat)?;
@@ -363,8 +374,20 @@ impl RustwideBuilder {
363374 }
364375 }
365376
377+ // FIXME: for now, purge all build dirs before each build.
378+ // Currently we have some error situations where the build directory wouldn't be deleted
379+ // after the build failed:
380+ // https://github.com/rust-lang/docs.rs/issues/820
381+ // This should be solved in a better way, likely refactoring the whole builder structure,
382+ // but for now we chose this simple way to prevent that the build directory remains can
383+ // fill up disk space.
384+ // This also prevents having multiple builders using the same rustwide workspace,
385+ // which we don't do. Currently our separate builders use a separate rustwide workspace.
386+ self.workspace
387+ .purge_all_build_dirs()
388+ .map_err(FailureError::compat)?;
389+
366390 let mut build_dir = self.workspace.build_dir(&format!("{name}-{version}"));
367- build_dir.purge().map_err(FailureError::compat)?;
368391
369392 let is_local = matches!(kind, PackageKind::Local(_));
370393 let krate = match kind {
@@ -564,7 +587,6 @@ impl RustwideBuilder {
564587 })
565588 .map_err(|e| e.compat())?;
566589
567- build_dir.purge().map_err(FailureError::compat)?;
568590 krate
569591 .purge_from_cache(&self.workspace)
570592 .map_err(FailureError::compat)?;
0 commit comments