Skip to content

Commit e862a48

Browse files
committed
Don't delete recordings.
This can help avoid accidentally deleting something that hasn't been checked in yet.
1 parent aa3d86a commit e862a48

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/test_record.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::BufWriter;
1212
use std::path::Path;
1313
use std::path::PathBuf;
1414
use std::sync::atomic::{AtomicU32, Ordering};
15-
use tracing::{error, info, warn};
15+
use tracing::{error, info};
1616

1717
/// A representation of the recording of activity of triagebot.
1818
///
@@ -89,18 +89,14 @@ fn next_sequence() -> u32 {
8989
/// `TRIAGEBOT_TEST_RECORD` environment variable is set.
9090
pub fn init() -> Result<()> {
9191
let Some(record_dir) = record_dir() else { return Ok(()) };
92+
if record_dir.exists() && record_dir.read_dir()?.next().is_some() {
93+
panic!(
94+
"{record_dir:?} already exists.\n\
95+
Delete the directory before recording if you wish to re-record that test."
96+
);
97+
}
9298
fs::create_dir_all(&record_dir)
9399
.with_context(|| format!("failed to create recording directory {record_dir:?}"))?;
94-
// Clear any old recording data.
95-
for entry in fs::read_dir(&record_dir)? {
96-
let entry = entry?;
97-
let path = entry.path();
98-
if path.extension().and_then(|p| p.to_str()) == Some("json") {
99-
warn!("deleting old recording at {path:?}");
100-
fs::remove_file(&path)
101-
.with_context(|| format!("failed to remove old recording {path:?}"))?;
102-
}
103-
}
104100
Ok(())
105101
}
106102

0 commit comments

Comments
 (0)