mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
Create cache file directory if it doesn't exist
This commit is contained in:
parent
4c9de35cc2
commit
c0338cac35
7 changed files with 22 additions and 10 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result<AuthResult, AuthError>
|
|||
},
|
||||
)
|
||||
.await {
|
||||
log::warn!("Error while caching auth data: {}", e);
|
||||
log::error!("{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Vec<CachedAccount>, Cache
|
|||
async fn set_entire_cache(cache_file: &Path, cache: Vec<CachedAccount>) -> 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
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue