Skip to content

Commit b245aee

Browse files
Purge caches from disk space thread
1 parent a5af91e commit b245aee

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
@@ -344,6 +344,7 @@ impl<'a> Worker<'a> {
344344
for dir in self.build_dir.values() {
345345
dir.lock().unwrap().purge()?;
346346
}
347+
347348
Ok(())
348349
}
349350

@@ -376,10 +377,10 @@ impl<'a> DiskSpaceWatcher<'a> {
376377
self.waiter.notify_all();
377378
}
378379

379-
pub(super) fn run(&self) {
380+
pub(super) fn run(&self, workspace: &Workspace) {
380381
let mut should_stop = self.should_stop.lock().unwrap();
381382
while !*should_stop {
382-
self.check();
383+
self.check(workspace);
383384
// Wait for either the interval to pass or should_stop to get a
384385
// write. We don't care if we timed out or not, we can double check
385386
// the should_stop regardless.
@@ -391,7 +392,7 @@ impl<'a> DiskSpaceWatcher<'a> {
391392
}
392393
}
393394

394-
fn check(&self) {
395+
fn check(&self, workspace: &Workspace) {
395396
let usage = match crate::utils::disk_usage::DiskUsage::fetch() {
396397
Ok(usage) => usage,
397398
Err(err) => {
@@ -406,6 +407,10 @@ impl<'a> DiskSpaceWatcher<'a> {
406407
for worker in self.workers {
407408
worker.schedule_target_dir_cleanup();
408409
}
410+
411+
if let Err(e) = workspace.purge_all_caches() {
412+
warn!("failed to purge caches: {:?}", e);
413+
}
409414
}
410415
}
411416
}

0 commit comments

Comments
 (0)