Mounting folders of backups (closes #5)

This commit is contained in:
Dennis Schwerdel 2017-04-13 14:24:58 +02:00
parent 8a57476da3
commit 05e710a938
2 changed files with 16 additions and 8 deletions

View File

@ -504,6 +504,9 @@ pub fn run() -> Result<(), ErrorCode> {
Arguments::Mount{repo_path, backup_name, inode, mount_point} => {
let mut repo = try!(open_repository(&repo_path));
let fs = if let Some(backup_name) = backup_name {
if repo.layout.backups_path().join(&backup_name).is_dir() {
checked!(FuseFilesystem::from_repository(&mut repo, Some(&backup_name)), "create fuse filesystem", ErrorCode::FuseMount)
} else {
let backup = try!(get_backup(&repo, &backup_name));
if let Some(inode) = inode {
let inode = checked!(repo.get_backup_inode(&backup, inode), "load subpath inode", ErrorCode::LoadInode);
@ -511,8 +514,9 @@ pub fn run() -> Result<(), ErrorCode> {
} else {
checked!(FuseFilesystem::from_backup(&mut repo, backup), "create fuse filesystem", ErrorCode::FuseMount)
}
}
} else {
checked!(FuseFilesystem::from_repository(&mut repo), "create fuse filesystem", ErrorCode::FuseMount)
checked!(FuseFilesystem::from_repository(&mut repo, None), "create fuse filesystem", ErrorCode::FuseMount)
};
info!("Mounting the filesystem...");
info!("Please unmount the filesystem via 'fusermount -u {}' when done.", mount_point);

View File

@ -153,9 +153,13 @@ impl<'a> FuseFilesystem<'a> {
})
}
pub fn from_repository(repository: &'a mut Repository) -> Result<Self, RepositoryError> {
pub fn from_repository(repository: &'a mut Repository, path: Option<&str>) -> Result<Self, RepositoryError> {
let mut backups = vec![];
for (name, backup) in try!(repository.get_all_backups()) {
let backup_map = match path {
Some(path) => try!(repository.get_backups(path)),
None => try!(repository.get_all_backups())
};
for (name, backup) in backup_map {
let inode = try!(repository.get_inode(&backup.root));
backups.push((name, backup, inode));
}