pub struct CleanupManager {
config: CleanupConfig,
program: QMProgram,
}Expand description
Manages cleanup operations for quantum chemistry calculations.
Fields§
§config: CleanupConfigCleanup configuration with whitelist
program: QMProgramQM program type
Implementations§
Source§impl CleanupManager
impl CleanupManager
Sourcepub fn new(config: CleanupConfig, program: QMProgram) -> Self
pub fn new(config: CleanupConfig, program: QMProgram) -> Self
Sourcepub fn cleanup_directory(&self, directory: &Path) -> Result<()>
pub fn cleanup_directory(&self, directory: &Path) -> Result<()>
Cleans up temporary files in the specified directory.
Uses a smart approach: preserves essential files and keeps only the latest .engrad files to prevent bus errors from excessive files.
§Arguments
directory- Path to the directory to clean (e.g., job directory from input file stem)
§Returns
Returns Ok(()) on success or a CleanupError on failure
Sourcefn find_max_step_number(&self, files: &[(PathBuf, String)]) -> usize
fn find_max_step_number(&self, files: &[(PathBuf, String)]) -> usize
Sourcefn extract_step_from_engrad(&self, filename: &str) -> Option<usize>
fn extract_step_from_engrad(&self, filename: &str) -> Option<usize>
Sourcepub fn should_preserve_file(
&self,
extension: &str,
_path: &Path,
filename: &str,
max_step: usize,
) -> bool
pub fn should_preserve_file( &self, extension: &str, _path: &Path, filename: &str, max_step: usize, ) -> bool
Determines if a file should be preserved (whitelist check with step-based filtering).
Files are preserved based on:
- Extension in whitelist (always keep)
- Special filename patterns (always keep)
- .engrad files from the latest step (keep only)
- All other files (delete)
§Arguments
extension- File extension without the dotpath- Full file pathfilename- Just the filenamemax_step- Maximum step number from .inp files
§Returns
Returns true if the file should be preserved, false otherwise
Sourcepub fn cleanup_file(&self, file_path: &Path) -> Result<bool>
pub fn cleanup_file(&self, file_path: &Path) -> Result<bool>
Cleans up a single file if it’s not in the whitelist.
Note: For .engrad files, this method conservatively deletes them unless they are from the latest step. To use step-based filtering, use cleanup_directory() instead.
§Arguments
file_path- Path to the file to clean
§Returns
Returns Ok(true) if file was deleted, Ok(false) if preserved
Sourcefn should_preserve_file_simple(&self, extension: &str, filename: &str) -> bool
fn should_preserve_file_simple(&self, extension: &str, filename: &str) -> bool
Sourcepub fn config(&self) -> &CleanupConfig
pub fn config(&self) -> &CleanupConfig
Gets the cleanup configuration (read-only).
Sourcepub fn would_preserve(&self, file_path: &Path) -> bool
pub fn would_preserve(&self, file_path: &Path) -> bool
Auto Trait Implementations§
impl Freeze for CleanupManager
impl RefUnwindSafe for CleanupManager
impl Send for CleanupManager
impl Sync for CleanupManager
impl Unpin for CleanupManager
impl UnsafeUnpin for CleanupManager
impl UnwindSafe for CleanupManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.