Fix the skin processing thread crashing on shutdown

This commit is contained in:
Thinkofname 2016-04-08 11:48:26 +01:00
parent 6cfef5af2d
commit accf01e1fb
1 changed files with 6 additions and 3 deletions

View File

@ -844,7 +844,10 @@ impl TextureManager {
use std::path::Path;
let client = hyper::Client::new();
loop {
let hash = recv.recv().unwrap();
let hash = match recv.recv() {
Ok(val) => val,
Err(_) => return, // Most likely shutting down
};
let path = format!("skin-cache/{}/{}.png", &hash[..2], hash);
let cache_path = Path::new(&path);
fs::create_dir_all(cache_path.parent().unwrap()).unwrap();
@ -865,7 +868,7 @@ impl TextureManager {
let mut img = match image::load_from_memory(&buf) {
Ok(val) => val,
Err(_) => {
reply.send((hash, None)).unwrap();
let _ = reply.send((hash, None));
continue;
}
};
@ -897,7 +900,7 @@ impl TextureManager {
}
}
}
reply.send((hash, Some(img))).unwrap();
let _ = reply.send((hash, Some(img)));
}
}