rust/hedgewars-server/src/server/io.rs
changeset 14790 a1077e8d26f4
parent 14786 01f8ab45f806
child 15079 c5a6e8566425
--- a/rust/hedgewars-server/src/server/io.rs	Wed Apr 10 19:30:08 2019 +0300
+++ b/rust/hedgewars-server/src/server/io.rs	Wed Apr 10 23:56:53 2019 +0300
@@ -46,13 +46,44 @@
                             &server_salt,
                         ) {
                             Ok(account) => IoResult::Account(account),
-                            Err(..) => {
-                                warn!("Unable to get account data: {}", 0);
+                            Err(e) => {
+                                warn!("Unable to get account data: {}", e);
                                 IoResult::Account(None)
                             }
                         }
                     }
 
+                    IoTask::GetReplay { id } => {
+                        let result = match db.get_replay_name(id) {
+                            Ok(Some(filename)) => {
+                                let filename = format!(
+                                    "checked/{}",
+                                    if filename.starts_with("replays/") {
+                                        &filename[8..]
+                                    } else {
+                                        &filename
+                                    }
+                                );
+                                match load_file(&filename) {
+                                    Ok(contents) => Some(unimplemented!()),
+                                    Err(e) => {
+                                        warn!(
+                                            "Error while writing the room config file \"{}\": {}",
+                                            filename, e
+                                        );
+                                        None
+                                    }
+                                }
+                            }
+                            Ok(None) => None,
+                            Err(e) => {
+                                warn!("Unable to get replay name: {}", e);
+                                None
+                            }
+                        };
+                        IoResult::Replay(result)
+                    }
+
                     IoTask::SaveRoom {
                         room_id,
                         filename,