Skip to content

Commit

Permalink
WIP, debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 2, 2024
1 parent d7d65f0 commit a20042f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/handler/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,13 @@ pub mod add_file {

file.save();

let rel_filename = rel_filename.unwrap();
let contents = file.buffer();

room.broadcast_json_except(
&serde_json::json!({
"method": METHOD,
"file": rel_filename.unwrap(),
"file": rel_filename,
"contents": contents,
"status": ST_SUCCESS,
}),
Expand Down Expand Up @@ -204,10 +205,12 @@ pub mod delete_file {
return;
}

let rel_filename = rel_filename.unwrap();

room.broadcast_json_except(
&serde_json::json!({
"method": METHOD,
"file": rel_filename.unwrap(),
"file": rel_filename,
"status": ST_SUCCESS,
}),
addr,
Expand Down Expand Up @@ -254,6 +257,12 @@ pub mod rename_file {

let file = room.rename_file(&filename, &newname);

let rel_filename = rel_filename.unwrap();
let rel_newname = rel_newname.unwrap();

println!("file: {}", rel_filename);
println!("rel_newname: {}", rel_newname);

// Failed to rename file.
if file.is_none() {
general_error(
Expand All @@ -268,8 +277,8 @@ pub mod rename_file {
room.broadcast_json_except(
&serde_json::json!({
"method": METHOD,
"file": rel_filename.unwrap(),
"newname": rel_newname.unwrap(),
"file": rel_filename,
"newname": rel_newname,
"status": ST_SUCCESS,
}),
addr,
Expand Down
2 changes: 1 addition & 1 deletion src/server/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn general_error(channel: &mut Channel, method: &str, msg: &str) {
channel
.send_json(&serde_json::json!({
"method": method,
"messag": format!("⛔ {}", msg),
"message": format!("⛔ {}", msg),
"status": ST_FAILURE,
}))
.await;
Expand Down

0 comments on commit a20042f

Please sign in to comment.