Skip to content

Commit

Permalink
Merge pull request #109 from genonullfree/fix-printlns
Browse files Browse the repository at this point in the history
Fix printlns
  • Loading branch information
genonullfree authored Feb 27, 2023
2 parents 74cd45a + c0134d4 commit 622abe5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "teleporter"
version = "0.10.7"
version = "0.10.8"
authors = ["geno nullfree <[email protected]>"]
license = "BSD-3-Clause"
description = "A small utility to send files quickly from point A to point B"
Expand Down
18 changes: 9 additions & 9 deletions src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn run(opt: ListenOpt) -> Result<(), TeleportError> {
Ok(l) => l,
Err(s) => {
println!(
"Cannot bind to port: {:?}. Is Teleporter already running?",
"Cannot bind to port: {}. Is Teleporter already running?",
&opt.port
);
return Err(TeleportError::Io(s));
Expand Down Expand Up @@ -150,7 +150,7 @@ fn handle_connection(

if !compatible {
println!(
"Error: Version mismatch from: {:?}! Us:{} Client:{:?}",
"Error: Version mismatch from: {:?}! Us:{} Client:{}",
ip, VERSION, header.version
);
let resp = TeleportInitAck::new(TeleportStatus::WrongVersion);
Expand Down Expand Up @@ -179,7 +179,7 @@ fn handle_connection(

// Test if overwrite is false and file exists
if !TeleportFeatures::Overwrite.check_u32(features) && Path::new(&filename).exists() {
println!(" => Refusing to overwrite file: {:?}", &filename);
println!(" => Refusing to overwrite file: {}", &filename);
let resp = TeleportInitAck::new(TeleportStatus::NoOverwrite);
return send_ack(resp, &mut stream, &enc);
}
Expand All @@ -189,7 +189,7 @@ fn handle_connection(
Some(p) => p,
None => {
println!(
"Error: unable to parse the path and filename: {:?}",
"Error: unable to parse the path and filename: {}",
&filename
);
let resp = TeleportInitAck::new(TeleportStatus::BadFileName);
Expand All @@ -198,7 +198,7 @@ fn handle_connection(
};

if fs::create_dir_all(path).is_err() {
println!("Error: unable to create directories: {:?}", &path);
println!("Error: unable to create directories: {}", &path.display());
let resp = TeleportInitAck::new(TeleportStatus::NoPermission);
return send_ack(resp, &mut stream, &enc);
};
Expand All @@ -215,7 +215,7 @@ fn handle_connection(
Err(_) => match File::create(&filename) {
Ok(f) => f,
Err(_) => {
println!("Error: unable to create file: {:?}", &filename);
println!("Error: unable to create file: {}", &filename);
let resp = TeleportInitAck::new(TeleportStatus::NoPermission);
return send_ack(resp, &mut stream, &enc);
}
Expand Down Expand Up @@ -290,11 +290,11 @@ fn handle_connection(
let speed =
(header.filesize as f64 * 8.0) / duration.as_secs() as f64 / 1024.0 / 1024.0;
println!(
" => Received file: {:?} (from: {:?} v{:?}) ({:.2?} @ {:.3} Mbps)",
" => Received file: {} (from: {} v{}) ({:.2?} @ {:.3} Mbps)",
&filename, ip, &header.version, duration, speed
);
} else {
println!(" => Error receiving: {:?}", &filename);
println!(" => Error receiving: {}", &filename);
}
break;
}
Expand All @@ -307,7 +307,7 @@ fn handle_connection(

if chunk.data_len as usize != wrote {
println!(
"Error writing to file: {:?} (read: {}, wrote: {}). Out of space?",
"Error writing to file: {} (read: {}, wrote: {}). Out of space?",
&filename, chunk.data_len, wrote
);
break;
Expand Down
6 changes: 3 additions & 3 deletions src/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,19 @@ pub fn run(mut opt: SendOpt) -> Result<(), TeleportError> {
// Validate response
match recv.status.try_into()? {
TeleportStatus::NoOverwrite => {
println!("The server refused to overwrite the file: {:?}", &filename);
println!("The server refused to overwrite the file: {}", &filename);
continue;
}
TeleportStatus::NoPermission => {
println!(
"The server does not have permission to write to this file: {:?}",
"The server does not have permission to write to this file: {}",
&filename
);
continue;
}
TeleportStatus::NoSpace => {
println!(
"The server has no space available to write the file: {:?}",
"The server has no space available to write the file: {}",
&filename
);
continue;
Expand Down

0 comments on commit 622abe5

Please sign in to comment.