aboutsummaryrefslogtreecommitdiffstats
path: root/src/server.rs
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-06-02 22:19:26 -0400
committerbnewbold <bnewbold@robocracy.org>2016-06-02 22:19:33 -0400
commitecd3f18f71cc1bf96c7500a3fa40c5fafdff1947 (patch)
treef4c1558c932d803d3e28c4d1d52dc3293d939ad6 /src/server.rs
parent0b058f570e71a3eaa1314a947fdff3d88193a63f (diff)
downloaducp-ecd3f18f71cc1bf96c7500a3fa40c5fafdff1947.tar.gz
ucp-ecd3f18f71cc1bf96c7500a3fa40c5fafdff1947.zip
massively improve io error handling
Slay many unwrap()'s
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/server.rs b/src/server.rs
index cb57499..cedcf8c 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -123,23 +123,28 @@ fn run_server(path: &str, is_recv: bool, recursive: bool, daemonize: bool, no_cr
info!("Got connection from {}", socket.getpeername().unwrap());
let mut stream: UdtStream = UdtStream::new(socket);
+ let io_result: io::Result<()>;
if !no_crypto {
let mut stream = SecretStream::new(stream);
stream.key = secret_key;
stream.read_nonce = read_nonce;
stream.write_nonce = write_nonce;
if is_recv {
- common::sink_files(&mut stream, path, recursive)
+ io_result = common::sink_files(&mut stream, path, recursive)
} else {
- common::source_files(&mut stream, path, recursive)
+ io_result = common::source_files(&mut stream, path, recursive)
}
} else {
if is_recv {
- common::sink_files(&mut stream, path, recursive)
+ io_result = common::sink_files(&mut stream, path, recursive)
} else {
- common::source_files(&mut stream, path, recursive)
+ io_result = common::source_files(&mut stream, path, recursive)
}
}
+ match io_result {
+ Ok(_) => Ok(()),
+ Err(e) => Err(e.description().to_string()),
+ }
}
fn usage_server(opts: Options) {