Skip to content

Commit

Permalink
move vfs layers to rustic_core
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome committed Jan 20, 2024
1 parent 54f4e92 commit ab77d51
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 880 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ simplelog = { workspace = true }
runtime-format = "0.1.3"
webdav-handler = {version = "0.2.0", features = ["warp-compat"]}
bytes = "1.5.0"
futures = "0.3.30"
tokio = "1.35.1"
warp = "0.3.6"

Expand Down
28 changes: 14 additions & 14 deletions src/commands/mount.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
//! `mount` subcommand
mod format;
pub mod fs;
mod mountfs;

use mountfs::RusticFS;

use std::{ffi::OsStr, path::PathBuf};

use crate::{commands::open_repository, status_err, Application, RUSTIC_APP};

use abscissa_core::{Command, Runnable, Shutdown};
use anyhow::Result;
use fuse_mt::{mount, FuseMT};
use rustic_core::vfs::{IdenticalSnapshot, Latest, Vfs};

#[derive(clap::Parser, Command, Debug)]
pub(crate) struct MountCmd {
Expand Down Expand Up @@ -44,30 +39,35 @@ impl Runnable for MountCmd {
impl MountCmd {
fn inner_run(&self) -> Result<()> {
let config = RUSTIC_APP.config();

let repo = open_repository(&config)?.to_indexed()?;
let repo = open_repository(&config.repository)?.to_indexed()?;

let path_template = self
.path_template
.clone()
.unwrap_or("[{hostname}]/[{label}]/{time}".to_string());
.unwrap_or_else(|| "[{hostname}]/[{label}]/{time}".to_string());
let time_template = self
.time_template
.clone()
.unwrap_or("%Y-%m-%d_%H-%M-%S".to_string());
.unwrap_or_else(|| "%Y-%m-%d_%H-%M-%S".to_string());

let sn_filter = |sn: &_| config.snapshot_filter.matches(sn);
let target_fs = if let Some(snap) = &self.snap {
let vfs = if let Some(snap) = &self.snap {
let node = repo.node_from_snapshot_path(snap, sn_filter)?;
RusticFS::from_node(repo, node)?
Vfs::from_dirnode(node)
} else {
let snapshots = repo.get_matching_snapshots(sn_filter)?;
RusticFS::from_snapshots(repo, snapshots, path_template, time_template)?
Vfs::from_snapshots(
snapshots,
path_template,
time_template,
Latest::AsLink,
IdenticalSnapshot::AsLink,
)?
};

let options = [OsStr::new("-o"), OsStr::new("fsname=rusticfs")];

let fs = FuseMT::new(target_fs, 1);
let fs = FuseMT::new(vfs.into_fuse_fs(repo), 1);
mount(fs, &self.mountpoint, &options)?;

Ok(())
Expand Down
37 changes: 0 additions & 37 deletions src/commands/mount/format.rs

This file was deleted.

229 changes: 0 additions & 229 deletions src/commands/mount/fs.rs

This file was deleted.

Loading

0 comments on commit ab77d51

Please sign in to comment.