rust/hedgewars-server/src/server/replaystorage.rs
changeset 15906 8f2ddbfdc0b4
parent 15903 212e16c60bf5
equal deleted inserted replaced
15904:f185e7367dd3 15906:8f2ddbfdc0b4
    22     pub fn pick_replay(&mut self, protocol: u16) -> Option<(ReplayId, Replay)> {
    22     pub fn pick_replay(&mut self, protocol: u16) -> Option<(ReplayId, Replay)> {
    23         let protocol_suffix = format!(".{}", protocol);
    23         let protocol_suffix = format!(".{}", protocol);
    24         let result = fs::read_dir("replays")
    24         let result = fs::read_dir("replays")
    25             .ok()?
    25             .ok()?
    26             .flat_map(|f| Some(f.ok()?.path()))
    26             .flat_map(|f| Some(f.ok()?.path()))
    27             .filter(|f| {
    27             .find(|f| {
    28                 f.ends_with(&protocol_suffix) && !self.borrowed_replays.iter().any(|e| &e.path == f)
    28                 f.ends_with(&protocol_suffix) && !self.borrowed_replays.iter().any(|e| &e.path == f)
    29             })
    29             })
    30             .next()
       
    31             .and_then(|f| {
    30             .and_then(|f| {
    32                 Some((
    31                 Some((
    33                     ReplayId { path: f.clone() },
    32                     ReplayId { path: f.clone() },
    34                     Replay::load(f.to_str()?).ok()?,
    33                     Replay::load(f.to_str()?).ok()?,
    35                 ))
    34                 ))