diff --git a/Cargo.lock b/Cargo.lock index 4696a48d..9f537122 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,7 +100,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "azalea" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "async-trait", @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "azalea-auth" -version = "0.2.1" +version = "0.2.2" dependencies = [ "azalea-buf", "azalea-crypto", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "azalea-client" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "azalea-auth", diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml index b532f779..4e26e6e4 100644 --- a/azalea-auth/Cargo.toml +++ b/azalea-auth/Cargo.toml @@ -3,7 +3,7 @@ description = "A port of Mojang's Authlib and launcher authentication." edition = "2021" license = "MIT" name = "azalea-auth" -version = "0.2.1" +version = "0.2.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 0cc36fcf..ec20d31e 100644 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -130,7 +130,7 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result }, ) .await { - log::warn!("Error while caching auth data: {}", e); + log::error!("{}", e); } } } diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs index e84c60fd..404b05ff 100644 --- a/azalea-auth/src/cache.rs +++ b/azalea-auth/src/cache.rs @@ -13,6 +13,8 @@ pub enum CacheError { Read(std::io::Error), #[error("Failed to write cache file: {0}")] Write(std::io::Error), + #[error("Failed to create cache file directory: {0}")] + MkDir(std::io::Error), #[error("Failed to parse cache file: {0}")] Parse(serde_json::Error), } @@ -73,6 +75,16 @@ async fn get_entire_cache(cache_file: &Path) -> Result, Cache async fn set_entire_cache(cache_file: &Path, cache: Vec) -> Result<(), CacheError> { log::trace!("saving cache: {:?}", cache); + if !cache_file.exists() { + let cache_file_parent = cache_file + .parent() + .expect("Cache file is root directory and also doesn't exist."); + log::debug!( + "Making cache file parent directory at {}", + cache_file_parent.to_string_lossy() + ); + std::fs::create_dir_all(cache_file_parent).map_err(CacheError::MkDir)?; + } let mut cache_file = File::create(cache_file).await.map_err(CacheError::Write)?; let cache = serde_json::to_string_pretty(&cache).map_err(CacheError::Parse)?; cache_file diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index b9a36e87..84df872a 100644 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -3,13 +3,13 @@ description = "A headless Minecraft client." edition = "2021" license = "MIT" name = "azalea-client" -version = "0.2.1" +version = "0.2.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] anyhow = "1.0.59" -azalea-auth = { path = "../azalea-auth", version = "0.2.0" } +azalea-auth = { path = "../azalea-auth", version = "0.2.1" } azalea-block = { path = "../azalea-block", version = "0.2.0" } azalea-chat = { path = "../azalea-chat", version = "0.2.0" } azalea-core = { path = "../azalea-core", version = "0.2.0" } diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml index ab43d18f..009c1344 100644 --- a/azalea-protocol/Cargo.toml +++ b/azalea-protocol/Cargo.toml @@ -10,7 +10,7 @@ version = "0.2.0" [dependencies] async-compression = {version = "^0.3.8", features = ["tokio", "zlib"], optional = true} async-recursion = "1.0.0" -azalea-auth = {path = "../azalea-auth", version = "^0.2.0" } +azalea-auth = {path = "../azalea-auth", version = "^0.2.1" } azalea-block = {path = "../azalea-block", default-features = false, version = "^0.2.0" } azalea-brigadier = {path = "../azalea-brigadier", version = "^0.2.0" } azalea-buf = {path = "../azalea-buf", version = "^0.2.0" } diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml index cfa8238f..e86dbde4 100644 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -3,14 +3,14 @@ description = "A framework for creating Minecraft bots." edition = "2021" license = "MIT" name = "azalea" -version = "0.2.3" +version = "0.2.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] anyhow = "^1.0.65" async-trait = "^0.1.57" -azalea-client = { version = "0.2.1", path = "../azalea-client" } +azalea-client = { version = "0.2.2", path = "../azalea-client" } azalea-protocol = { version = "0.2.0", path = "../azalea-protocol" } parking_lot = "^0.12.1" thiserror = "^1.0.37"