Add authorized file-root sync
This commit is contained in:
parent
0e3ca7e80a
commit
1caaedda90
7 changed files with 489 additions and 11 deletions
|
|
@ -286,9 +286,20 @@ pub enum CasCommand {
|
|||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum CasRootCommand {
|
||||
Add { name: String, path: PathBuf },
|
||||
Add {
|
||||
name: String,
|
||||
path: PathBuf,
|
||||
},
|
||||
List,
|
||||
Scan { name: String },
|
||||
Scan {
|
||||
name: String,
|
||||
},
|
||||
Sync {
|
||||
node: String,
|
||||
name: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -731,6 +742,15 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
CasRootCommand::Add { name, path } => ControlRequest::CasRootAdd { name, path },
|
||||
CasRootCommand::List => ControlRequest::CasRootList,
|
||||
CasRootCommand::Scan { name } => ControlRequest::CasRootScan { name },
|
||||
CasRootCommand::Sync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
} => ControlRequest::CasRootSync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
CasCommand::Conflict { command } => match command {
|
||||
CasConflictCommand::Record {
|
||||
|
|
@ -1244,6 +1264,37 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
}
|
||||
println!("note: {}", scan.note);
|
||||
}
|
||||
ControlResponse::CasRootSynced {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
endpoint_id,
|
||||
name,
|
||||
root,
|
||||
tree_bytes_imported,
|
||||
allowed,
|
||||
reason,
|
||||
note,
|
||||
} => {
|
||||
if let Some(root) = root {
|
||||
println!("synced file root: {name}");
|
||||
println!("peer: {peer_node_id}");
|
||||
println!("path: {}", root.path);
|
||||
println!(
|
||||
"tree: {}",
|
||||
root.latest_tree
|
||||
.map(|hash| hash.to_string())
|
||||
.unwrap_or_else(|| "unscanned".to_owned())
|
||||
);
|
||||
println!("tree_bytes_imported: {tree_bytes_imported}");
|
||||
} else {
|
||||
println!("file root sync denied by {peer_node_id}");
|
||||
}
|
||||
println!("agent: {peer_agent_id}");
|
||||
println!("endpoint: {endpoint_id}");
|
||||
println!("allowed: {allowed}");
|
||||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::CasConflictRecorded { conflict } => {
|
||||
println!("recorded conflict: {}", conflict.id);
|
||||
print_file_conflict(&conflict);
|
||||
|
|
|
|||
Loading…
Reference in a new issue