pub fn remove_tmp_snapshot_archives(snapshot_archives_dir: impl AsRef<Path>) {
    if let Ok(entries) = fs::read_dir(snapshot_archives_dir) {
        for entry in entries.filter_map(|entry| entry.ok()) {
            let file_name = entry
                .file_name()
                .into_string()
                .unwrap_or_else(|_| String::new());
            if file_name.starts_with(TMP_SNAPSHOT_ARCHIVE_PREFIX) {
                if entry.path().is_file() {
                    fs::remove_file(entry.path())
                } else {
                    fs::remove_dir_all(entry.path())
                }
                .unwrap_or_else(|err| {
                    warn!("Failed to remove {}: {}", entry.path().display(), err)
                });
            }
        }
    }
}
/// If the validator halts in the middle of `archive_snapshot_package()`, the temporary staging
/// directory won't be cleaned up.  Call this function to clean them up.
If the validator halts in the middle of `archive_snapshot_package()`, the temporary staging
directory won't be cleaned up.  Call this function to clean them up.
If the validator halts in the middle of ` archive_snapshot_package () ` the temporary staging directory won ' t be cleaned up . Call this function to clean them up .
pub fn remove_tmp_snapshot_archives(snapshot_archives_dir: impl AsRef<Path>) {
    if let Ok(entries) = fs::read_dir(snapshot_archives_dir) {
        for entry in entries.filter_map(|entry| entry.ok()) {
            let file_name = entry
                .file_name()
                .into_string()
                .unwrap_or_else(|_| String::new());
            if file_name.starts_with(TMP_SNAPSHOT_ARCHIVE_PREFIX) {
                if entry.path().is_file() {
                    fs::remove_file(entry.path())
                } else {
                    fs::remove_dir_all(entry.path())
                }
                .unwrap_or_else(|err| {
                    warn!("Failed to remove {}: {}", entry.path().display(), err)
                });
            }
        }
    }
}
pub fn remove_tmp_snapshot_archives ( snapshot_archives_dir : impl AsRef < Path > ) { if let Ok ( entries ) = fs :: read_dir ( snapshot_archives_dir ) { for entry in entries . filter_map ( | entry | entry . ok ( ) ) { let file_name = entry . file_name ( ) . into_string ( ) . unwrap_or_else ( | _ | String :: new ( ) ) ; if file_name . starts_with ( TMP_SNAPSHOT_ARCHIVE_PREFIX ) { if entry . path ( ) . is_file ( ) { fs :: remove_file ( entry . path ( ) ) } else { fs :: remove_dir_all ( entry . path ( ) ) } . unwrap_or_else ( | err | { warn ! ( " " entry path ( ) display ( ) err ) } ) ; } } } }
If the validator halts in the middle of `archive_snapshot_package()`, the temporary staging
directory won't be cleaned up.
If the validator halts in the middle of ` archive_snapshot_package () ` the temporary staging directory won ' t be cleaned up .
snapshot_archives_dir
impl AsRef<Path>