Delete a task's persisted data when appropriate

This commit is contained in:
Loïc Lecrenier 2022-10-18 15:04:14 +02:00 committed by Clément Renault
parent f7e546eea3
commit ea60d35c71
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
19 changed files with 116 additions and 11 deletions

View file

@ -1,6 +1,8 @@
use std::collections::BTreeSet;
use std::fs::File as StdFile;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use tempfile::NamedTempFile;
use uuid::Uuid;
@ -96,6 +98,20 @@ impl FileStore {
std::fs::remove_file(path)?;
Ok(())
}
/// List the Uuids of the files in the FileStore
///
/// This function is meant to be used by tests only.
#[doc(hidden)]
pub fn __all_uuids(&self) -> BTreeSet<Uuid> {
let mut uuids = BTreeSet::new();
for entry in self.path.read_dir().unwrap() {
let entry = entry.unwrap();
let uuid = Uuid::from_str(entry.file_name().to_str().unwrap()).unwrap();
uuids.insert(uuid);
}
uuids
}
}
pub struct File {