Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Oct 21, 2024
1 parent 03dcac0 commit 483e278
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 189 deletions.
3 changes: 1 addition & 2 deletions remotefs-fuse-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ fn main() -> anyhow::Result<()> {
let args = argh::from_env::<cli::CliArgs>();
let mount_path = args.to.clone();
let remote = args.remote();
let data_dir = TempDir::new()?;

let driver = Driver::new(data_dir.path(), remote)?;
let driver = Driver::new(remote);

// setup signal handler
ctrlc::set_handler(move || {
Expand Down
4 changes: 2 additions & 2 deletions remotefs-fuse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ path = "src/lib.rs"
log = "^0.4"
remotefs = "0.3"
thiserror = "^1"
tempfile = "^3"

[target.'cfg(target_family = "unix")'.dependencies]
fuser = "0.14"
libc = "^0.2"
seahash = "4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "^1"

[dev-dependencies]
env_logger = "^0.11"
pretty_assertions = "^1"
remotefs-ssh = "0.4"
tempfile = "^3"


[features]
default = []
Expand Down
13 changes: 4 additions & 9 deletions remotefs-fuse/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ mod error;
#[cfg_attr(docsrs, doc(cfg(target_family = "unix")))]
mod unix;

use std::path::{Path, PathBuf};

use remotefs::RemoteFs;

pub use self::error::{DriverError, DriverResult};
Expand All @@ -16,7 +14,6 @@ pub use self::error::{DriverError, DriverResult};
/// The driver will use the [`fuser`](https://crates.io/crates/fuser) crate to mount the filesystem, on Unix systems, while
/// it will use [dokan](https://crates.io/crates/dokan) on Windows.
pub struct Driver {
data_dir: PathBuf,
#[cfg(target_family = "unix")]
database: unix::InodeDb,
remote: Box<dyn RemoteFs>,
Expand All @@ -29,14 +26,12 @@ impl Driver {
///
/// # Arguments
///
/// * `data_dir` - A directory where inodes will be mapped.
/// * `remote` - The instance which implements the [`RemoteFs`] trait.
pub fn new(data_dir: &Path, remote: Box<dyn RemoteFs>) -> DriverResult<Self> {
Ok(Self {
data_dir: data_dir.to_path_buf(),
pub fn new(remote: Box<dyn RemoteFs>) -> Self {
Self {
#[cfg(target_family = "unix")]
database: unix::InodeDb::load(&data_dir.join("inodes.json"))?,
database: unix::InodeDb::load(),
remote,
})
}
}
}
6 changes: 1 addition & 5 deletions remotefs-fuse/src/driver/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ use thiserror::Error;
pub type DriverResult<T> = Result<T, DriverError>;

#[derive(Debug, Error)]
pub enum DriverError {
#[cfg(target_family = "unix")]
#[error("Inode DB error: {0}")]
Inode(#[from] super::unix::InodeDbError),
}
pub enum DriverError {}
Loading

0 comments on commit 483e278

Please sign in to comment.