wip
This commit is contained in:
@@ -6,6 +6,7 @@ mod peer;
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
io::ErrorKind,
|
||||
net::{IpAddr, SocketAddr},
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
@@ -1162,6 +1163,29 @@ async fn retry_failed_chunks(
|
||||
/// Load local game database combining locally installed games
|
||||
async fn load_local_game_db(game_dir: &str) -> eyre::Result<GameDB> {
|
||||
let game_path = PathBuf::from(game_dir);
|
||||
|
||||
let metadata = match tokio::fs::metadata(&game_path).await {
|
||||
Ok(metadata) => metadata,
|
||||
Err(err) => {
|
||||
if err.kind() == ErrorKind::NotFound {
|
||||
log::warn!(
|
||||
"Local game directory {} missing; reporting empty game database",
|
||||
game_path.display()
|
||||
);
|
||||
return Ok(GameDB::empty());
|
||||
}
|
||||
return Err(err.into());
|
||||
}
|
||||
};
|
||||
|
||||
if !metadata.is_dir() {
|
||||
log::warn!(
|
||||
"Configured game directory {} is not a directory; reporting empty game database",
|
||||
game_path.display()
|
||||
);
|
||||
return Ok(GameDB::empty());
|
||||
}
|
||||
|
||||
let mut games = Vec::new();
|
||||
|
||||
// Scan game directory and create entries for installed games
|
||||
|
||||
Reference in New Issue
Block a user