Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ agentfs-sdk = { path = "../sdk/rust" }
tokio = { version = "1", features = ["full"] }
clap = { version = "4", features = ["derive"] }
anyhow = "1.0"
turso = { version = "0.4.3-pre.2", features = ["sync"] }
turso = { version = "0.4.4-pre.1", features = ["sync"] }
serde = { version = "1.0", features = ["derive"] }
parking_lot = "0.12.5"
clap_complete = { version = "=4.5.61", features = ["unstable-dynamic"] }
Expand Down
74 changes: 38 additions & 36 deletions cli/src/cmd/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,48 @@ pub fn mount(args: MountArgs) -> Result<()> {

let mount = move || {
let rt = crate::get_runtime();
let agentfs = rt.block_on(open_agentfs(opts))?;

// Check for overlay configuration
let fs: Arc<dyn FileSystem> = rt.block_on(async {
let conn = agentfs.get_connection().await?;

// Check if fs_overlay_config table exists and has base_path
let query = "SELECT value FROM fs_overlay_config WHERE key = 'base_path'";
let base_path: Option<String> = match conn.query(query, ()).await {
Ok(mut rows) => {
if let Ok(Some(row)) = rows.next().await {
row.get_value(0).ok().and_then(|v| {
if let Value::Text(s) = v {
Some(s.clone())
} else {
None
}
})
} else {
None
rt.block_on(async {
let agentfs = open_agentfs(opts).await?;

// Check for overlay configuration
let fs: Arc<dyn FileSystem> = {
let conn = agentfs.get_connection().await?;

// Check if fs_overlay_config table exists and has base_path
let query = "SELECT value FROM fs_overlay_config WHERE key = 'base_path'";
let base_path: Option<String> = match conn.query(query, ()).await {
Ok(mut rows) => {
if let Ok(Some(row)) = rows.next().await {
row.get_value(0).ok().and_then(|v| {
if let Value::Text(s) = v {
Some(s.clone())
} else {
None
}
})
} else {
None
}
}
Err(_) => None, // Table doesn't exist or query failed
};

if let Some(base_path) = base_path {
// Create OverlayFS with HostFS base
eprintln!("Using overlay filesystem with base: {}", base_path);
let hostfs = HostFS::new(&base_path)?;
#[cfg(target_family = "unix")]
let hostfs = { hostfs.with_fuse_mountpoint(mountpoint_ino) };
let overlay = OverlayFS::new(Arc::new(hostfs), agentfs.fs);
Arc::new(overlay) as Arc<dyn FileSystem>
} else {
// Plain AgentFS
Arc::new(agentfs.fs) as Arc<dyn FileSystem>
}
Err(_) => None, // Table doesn't exist or query failed
};

if let Some(base_path) = base_path {
// Create OverlayFS with HostFS base
eprintln!("Using overlay filesystem with base: {}", base_path);
let hostfs = HostFS::new(&base_path)?;
#[cfg(target_family = "unix")]
let hostfs = { hostfs.with_fuse_mountpoint(mountpoint_ino) };
let overlay = OverlayFS::new(Arc::new(hostfs), agentfs.fs);
Ok::<Arc<dyn FileSystem>, anyhow::Error>(Arc::new(overlay))
} else {
// Plain AgentFS
Ok(Arc::new(agentfs.fs) as Arc<dyn FileSystem>)
}
})?;

crate::fuse::mount(fs, fuse_opts, rt)
crate::fuse::mount(fs, fuse_opts).await
})
};

if args.foreground {
Expand Down
Loading
Loading