Skip to content

Commit

Permalink
Update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
NORTHAMERICA\mayurikini committed Nov 11, 2024
1 parent 96d4ead commit b0526f1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ impl Server {
let file_path = &self.send_directory.join(file_path);
match check_file_exists(file_path, &self.send_directory) {
ErrorCode::FileNotFound => {
println!("File not found: {}", file_path.display());
println!("File {} not found", file_path.display());
Socket::send_to(
&self.socket,
&Packet::Error {
code: ErrorCode::FileNotFound,
msg: "file does not exist".to_string(),
msg: format!("file {} does not exist", file_path.display()),
},
to,
)
Expand Down Expand Up @@ -246,7 +246,7 @@ impl Server {
if self.overwrite {
initialize_write()
} else {
println!("File exists {}, cannot override.", file_path.display());
println!("File {} already exists.", file_path.display());
Socket::send_to(
&self.socket,
&Packet::Error {
Expand Down Expand Up @@ -298,7 +298,9 @@ enum RequestType {
}

pub fn convert_file_path(filename: &str) -> PathBuf {
let formatted_filename = filename.trim_start_matches(|c| c == '/' || c == '\\').to_string();
let formatted_filename = filename
.trim_start_matches(|c| c == '/' || c == '\\')
.to_string();
let normalized_filename = if MAIN_SEPARATOR == '\\' {
formatted_filename.replace('/', "\\")
} else {
Expand Down Expand Up @@ -416,7 +418,7 @@ mod tests {
let mut correct_path = PathBuf::new();
correct_path.push("test.file");
assert_eq!(path, correct_path);

let path = convert_file_path("/test.file");
let mut correct_path = PathBuf::new();
correct_path.push("test.file");
Expand Down

0 comments on commit b0526f1

Please sign in to comment.