src/backup/backup_info.rs: new list_groups helper
This commit is contained in:
		| @ -37,7 +37,7 @@ lazy_static!{ | ||||
| } | ||||
|  | ||||
| /// BackupGroup is a directory containing a list of BackupDir | ||||
| #[derive(Debug, Clone)] | ||||
| #[derive(Debug, Eq, PartialEq, Hash, Clone)] | ||||
| pub struct BackupGroup { | ||||
|     /// Type of backup | ||||
|     backup_type: String, | ||||
| @ -137,6 +137,19 @@ impl BackupGroup { | ||||
|         Ok(last) | ||||
|     } | ||||
|  | ||||
|     pub fn list_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> { | ||||
|         let mut list = Vec::new(); | ||||
|  | ||||
|         tools::scandir(libc::AT_FDCWD, base_path, &BACKUP_TYPE_REGEX, |l0_fd, backup_type, file_type| { | ||||
|             if file_type != nix::dir::Type::Directory { return Ok(()); } | ||||
|             tools::scandir(l0_fd, backup_type, &BACKUP_ID_REGEX, |_l1_fd, backup_id, file_type| { | ||||
|                 if file_type != nix::dir::Type::Directory { return Ok(()); } | ||||
|                 list.push(BackupGroup::new(backup_type, backup_id)); | ||||
|                 Ok(()) | ||||
|             }) | ||||
|         })?; | ||||
|         Ok(list) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// Uniquely identify a Backup (relative to data store) | ||||
| @ -249,7 +262,7 @@ impl BackupInfo { | ||||
|     } | ||||
|  | ||||
|     pub fn list_backups(base_path: &Path) -> Result<Vec<BackupInfo>, Error> { | ||||
|         let mut list = vec![]; | ||||
|         let mut list = Vec::new(); | ||||
|  | ||||
|         tools::scandir(libc::AT_FDCWD, base_path, &BACKUP_TYPE_REGEX, |l0_fd, backup_type, file_type| { | ||||
|             if file_type != nix::dir::Type::Directory { return Ok(()); } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user