fix inverted cond on deleting sample file dir

Symptom: in `nvr config`, if you create a dir and then immediately try
to delete it, it would fail saying it's in-use. This check is supposed
to be for having a running syncer on the directory, which would be
an arc count > 1.
This commit is contained in:
Scott Lamb 2022-10-01 13:16:28 -07:00
parent 8b50a45ab0
commit a5824b8633
1 changed files with 8 additions and 3 deletions

View File

@ -1809,11 +1809,16 @@ impl LockedDatabase {
let dir = match d.get_mut().dir.take() {
None => dir::SampleFileDir::open(&d.get().path, &d.get().expected_meta(&self.uuid))?,
Some(arc) => match Arc::strong_count(&arc) {
1 => {
1 => arc, // LockedDatabase is only reference
c => {
// a writer::Syncer also has a reference.
d.get_mut().dir = Some(arc); // put it back.
bail!("can't delete in-use directory {}", dir_id);
bail!(
"can't delete directory {} with active syncer (refcnt {}",
dir_id,
c
);
}
_ => arc,
},
};
if !dir.is_empty()? {