diff --git a/src/backup/backup_info.rs b/src/backup/backup_info.rs index 0fa7f1e6..ab63beb8 100644 --- a/src/backup/backup_info.rs +++ b/src/backup/backup_info.rs @@ -157,10 +157,25 @@ impl BackupInfo { } } - pub fn list_backups(path: &Path) -> Result, Error> { + pub fn list_files(base_path: &Path, backup_dir: &BackupDir) -> Result, Error> { + let mut path = base_path.to_owned(); + path.push(backup_dir.relative_path()); + + let mut files = vec![]; + + tools::scandir(libc::AT_FDCWD, &path, &BACKUP_FILE_REGEX, |_, filename, file_type| { + if file_type != nix::dir::Type::File { return Ok(()); } + files.push(filename.to_owned()); + Ok(()) + })?; + + Ok(files) + } + + pub fn list_backups(base_path: &Path) -> Result, Error> { let mut list = vec![]; - tools::scandir(libc::AT_FDCWD, path, &BACKUP_TYPE_REGEX, |l0_fd, backup_type, file_type| { + 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(()); } diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index a0e69b09..429da66e 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -168,6 +168,11 @@ impl DataStore { BackupInfo::list_backups(&path) } + pub fn list_files(&self, backup_dir: &BackupDir) -> Result, Error> { + let path = self.base_path(); + BackupInfo::list_files(&path, backup_dir) + } + pub fn list_images(&self) -> Result, Error> { let base = self.base_path();