Refine peer networking and chunked file transfers
This commit is contained in:
@@ -179,6 +179,8 @@ pub struct GameFileDescription {
|
||||
pub game_id: String,
|
||||
pub relative_path: String,
|
||||
pub is_dir: bool,
|
||||
#[serde(default)]
|
||||
pub size: Option<u64>,
|
||||
}
|
||||
|
||||
impl GameFileDescription {
|
||||
@@ -186,6 +188,11 @@ impl GameFileDescription {
|
||||
pub fn is_version_ini(&self) -> bool {
|
||||
self.relative_path.ends_with("/version.ini")
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn file_size(&self) -> Option<u64> {
|
||||
if self.is_dir { None } else { self.size }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for GameFileDescription {
|
||||
@@ -193,10 +200,11 @@ impl fmt::Debug for GameFileDescription {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}: [{}] path:{}",
|
||||
"{}: [{}] path:{} size:{}",
|
||||
self.game_id,
|
||||
if self.is_dir { 'D' } else { 'F' },
|
||||
self.relative_path,
|
||||
self.size.unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user