mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 02:20:43 +08:00
node: Add track/untrack support
Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
@@ -60,8 +60,36 @@ enum DrainError {
|
||||
fn drain<H: Handle>(stream: &UnixStream, handle: &H) -> Result<(), DrainError> {
|
||||
let mut reader = BufReader::new(stream);
|
||||
|
||||
// TODO: refactor to include helper
|
||||
for line in reader.by_ref().lines().flatten() {
|
||||
match line.split_once(' ') {
|
||||
Some(("fetch", arg)) => {
|
||||
if let Ok(id) = arg.parse() {
|
||||
if let Err(e) = handle.fetch(id) {
|
||||
return Err(DrainError::Client(e));
|
||||
}
|
||||
} else {
|
||||
return Err(DrainError::InvalidCommandArg(arg.to_owned()));
|
||||
}
|
||||
}
|
||||
Some(("track", arg)) => {
|
||||
if let Ok(id) = arg.parse() {
|
||||
if let Err(e) = handle.track(id) {
|
||||
return Err(DrainError::Client(e));
|
||||
}
|
||||
} else {
|
||||
return Err(DrainError::InvalidCommandArg(arg.to_owned()));
|
||||
}
|
||||
}
|
||||
Some(("untrack", arg)) => {
|
||||
if let Ok(id) = arg.parse() {
|
||||
if let Err(e) = handle.untrack(id) {
|
||||
return Err(DrainError::Client(e));
|
||||
}
|
||||
} else {
|
||||
return Err(DrainError::InvalidCommandArg(arg.to_owned()));
|
||||
}
|
||||
}
|
||||
Some(("update", arg)) => {
|
||||
if let Ok(id) = arg.parse() {
|
||||
if let Err(e) = handle.updated(id) {
|
||||
|
||||
Reference in New Issue
Block a user