Skip to content

Commit ae5cafa

Browse files
Merge pull request rust-lang#798 from Mark-Simulacrum/prepare-fail
Purge caches from disk space thread
2 parents 451e818 + b245aee commit ae5cafa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/runner/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn run_ex(
102102
std::thread::Builder::new()
103103
.name("disk-space-watcher".into())
104104
.spawn_scoped(scope1, || {
105-
disk_watcher.run();
105+
disk_watcher.run(workspace);
106106
})
107107
.unwrap();
108108

src/runner/worker.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ impl<'a> Worker<'a> {
347347
for dir in self.build_dir.values() {
348348
dir.lock().unwrap().purge()?;
349349
}
350+
350351
Ok(())
351352
}
352353

@@ -379,10 +380,10 @@ impl<'a> DiskSpaceWatcher<'a> {
379380
self.waiter.notify_all();
380381
}
381382

382-
pub(super) fn run(&self) {
383+
pub(super) fn run(&self, workspace: &Workspace) {
383384
let mut should_stop = self.should_stop.lock().unwrap();
384385
while !*should_stop {
385-
self.check();
386+
self.check(workspace);
386387
// Wait for either the interval to pass or should_stop to get a
387388
// write. We don't care if we timed out or not, we can double check
388389
// the should_stop regardless.
@@ -394,7 +395,7 @@ impl<'a> DiskSpaceWatcher<'a> {
394395
}
395396
}
396397

397-
fn check(&self) {
398+
fn check(&self, workspace: &Workspace) {
398399
let usage = match crate::utils::disk_usage::DiskUsage::fetch() {
399400
Ok(usage) => usage,
400401
Err(err) => {
@@ -409,6 +410,10 @@ impl<'a> DiskSpaceWatcher<'a> {
409410
for worker in self.workers {
410411
worker.schedule_target_dir_cleanup();
411412
}
413+
414+
if let Err(e) = workspace.purge_all_caches() {
415+
warn!("failed to purge caches: {:?}", e);
416+
}
412417
}
413418
}
414419
}

0 commit comments

Comments
 (0)