[code] improve structure (focus: server)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
#![allow(clippy::doc_markdown)]
|
||||
|
||||
use std::{collections::HashMap, fmt};
|
||||
use std::{collections::HashMap, fmt, path::Path};
|
||||
|
||||
use bytes::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -93,6 +93,17 @@ impl GameDB {
|
||||
db
|
||||
}
|
||||
|
||||
pub fn add_thumbnails(&mut self, thumbs_dir: &Path) {
|
||||
for game in self.games.values_mut() {
|
||||
let asset = thumbs_dir.join(format!("{}.jpg", game.id));
|
||||
if let Ok(data) = std::fs::read(&asset) {
|
||||
game.thumbnail = Some(Bytes::from(data));
|
||||
} else {
|
||||
tracing::warn!("Thumbnail missing: {}", game.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_game_by_id<S>(&self, id: S) -> Option<&Game>
|
||||
where
|
||||
|
Reference in New Issue
Block a user