From a393e0a2f2c3678a3ea869dc1417fa269f2b1040 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Sat, 24 Jan 2026 08:29:14 +0100 Subject: Resolve audio not loading bug Ensure all assets are downloading for each version Temporarily disable minecraft versions older than 1.8 because of the asset/manifest loading issues Implement basic documentation of modules Implement basic async/multithreading for downloading assets --- src/util/fs.rs | 4 +++- src/util/mod.rs | 12 ++++++++++++ src/util/sha1.rs | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/fs.rs b/src/util/fs.rs index b86c0d7..8ecd0d0 100644 --- a/src/util/fs.rs +++ b/src/util/fs.rs @@ -2,11 +2,13 @@ use std::path::Path; +use tokio::fs::remove_file; + use crate::errors::McError; pub async fn remove_if_exists(path: &Path) -> Result<(), McError> { if path.exists() { - tokio::fs::remove_file(path).await?; + remove_file(path).await?; } Ok(()) } diff --git a/src/util/mod.rs b/src/util/mod.rs index 8176b9b..b8531c6 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,2 +1,14 @@ +//! Utility module for the DML launcher. +//! +//! This module contains general-purpose helper functions used throughout +//! the project. It is designed to provide reusable functionality without +//! being specific to Minecraft or configuration. +//! +//! # Submodules +//! - `fs`: File system utilities such as safe file creation, reading, and +//! writing. +//! - `sha1`: Functions to compute SHA-1 hashes for files and data integrity +//! checks. + pub mod fs; pub mod sha1; diff --git a/src/util/sha1.rs b/src/util/sha1.rs index c5f1021..6684963 100644 --- a/src/util/sha1.rs +++ b/src/util/sha1.rs @@ -3,11 +3,12 @@ use std::path::Path; use sha1::{Digest, Sha1}; +use tokio::fs::read; use crate::errors::McError; pub async fn sha1_hex(path: &Path) -> Result { - let data = tokio::fs::read(path).await?; + let data = read(path).await?; let mut hasher = Sha1::new(); hasher.update(&data); Ok(format!("{:x}", hasher.finalize())) -- cgit v1.2.3