🐛 fix: clippy lints
Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
parent
8c99ee1b1f
commit
a357df0b2d
28 changed files with 230 additions and 227 deletions
110
Cargo.lock
generated
110
Cargo.lock
generated
|
|
@ -340,7 +340,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -375,7 +375,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -811,9 +811,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.21"
|
||||
version = "1.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0"
|
||||
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
|
@ -1276,7 +1276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1286,7 +1286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1357,7 +1357,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1381,7 +1381,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1392,7 +1392,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
|
|||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1464,7 +1464,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1477,7 +1477,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1608,7 +1608,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1631,7 +1631,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1837,7 +1837,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2063,7 +2063,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2175,7 +2175,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2472,7 +2472,7 @@ dependencies = [
|
|||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2572,7 +2572,7 @@ dependencies = [
|
|||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3859,7 +3859,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3869,6 +3868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4199,7 +4199,7 @@ dependencies = [
|
|||
"proc-macro-crate 2.0.2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4467,7 +4467,7 @@ name = "onelauncher_macros"
|
|||
version = "1.0.0-alpha.1"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4561,7 +4561,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4843,7 +4843,7 @@ dependencies = [
|
|||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4971,7 +4971,7 @@ dependencies = [
|
|||
"phf_shared 0.11.2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -5018,7 +5018,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -5075,15 +5075,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.13"
|
||||
version = "0.17.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1"
|
||||
checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide 0.7.4",
|
||||
"miniz_oxide 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6073,9 +6073,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.8.0"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
|
||||
checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
|
|
@ -6211,7 +6211,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_derive_internals",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6341,7 +6341,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6352,7 +6352,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6397,7 +6397,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6448,7 +6448,7 @@ dependencies = [
|
|||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -6737,7 +6737,7 @@ dependencies = [
|
|||
"Inflector",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7018,7 +7018,7 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7051,9 +7051,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.77"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -7214,7 +7214,7 @@ checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7330,7 +7330,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.8",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
"tauri-utils",
|
||||
"thiserror",
|
||||
"time",
|
||||
|
|
@ -7348,7 +7348,7 @@ dependencies = [
|
|||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
"tauri-codegen",
|
||||
"tauri-utils",
|
||||
]
|
||||
|
|
@ -7597,7 +7597,7 @@ dependencies = [
|
|||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7701,7 +7701,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7807,7 +7807,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -7962,7 +7962,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8453,7 +8453,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
|
@ -8487,7 +8487,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
|
@ -8614,7 +8614,7 @@ checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8784,7 +8784,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8795,7 +8795,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8806,7 +8806,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -8817,7 +8817,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -9344,7 +9344,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -9365,7 +9365,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -217,9 +217,6 @@ complexity = { level = "warn", priority = -1 }
|
|||
nursery = { level = "warn", priority = -1 }
|
||||
unnecessary_cast = "warn"
|
||||
cast_lossless = "warn"
|
||||
cast_possible_truncation = "warn"
|
||||
cast_possible_wrap = "warn"
|
||||
cast_sign_loss = "warn"
|
||||
dbg_macro = "warn"
|
||||
deprecated_cfg_attr = "warn"
|
||||
separated_literal_suffix = "warn"
|
||||
|
|
@ -229,6 +226,8 @@ module_name_repetitions = "allow"
|
|||
struct_field_names = "allow"
|
||||
cast_precision_loss = "allow"
|
||||
missing_panics_doc = "allow"
|
||||
significant_drop_tightening = "allow" # tmp
|
||||
needless_return = "allow"
|
||||
|
||||
[workspace.lints.rust]
|
||||
unused_qualifications = "warn"
|
||||
|
|
|
|||
|
|
@ -15,22 +15,19 @@ use uuid::Uuid;
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_cluster(uuid: Uuid) -> Result<Cluster, String> {
|
||||
match onelauncher::cluster::get_by_uuid(uuid).await? {
|
||||
Some(cluster) => Ok(cluster),
|
||||
None => Err("Cluster does not exist".into()),
|
||||
}
|
||||
(cluster::get_by_uuid(uuid).await?).map_or_else(|| Err("Cluster does not exist".into()), Ok)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_clusters() -> Result<Vec<Cluster>, String> {
|
||||
Ok(onelauncher::cluster::list().await?)
|
||||
Ok(cluster::list().await?)
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_clusters_grouped() -> Result<HashMap<String, Vec<Cluster>>, String> {
|
||||
Ok(onelauncher::cluster::list_grouped().await?)
|
||||
Ok(cluster::list_grouped().await?)
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type)]
|
||||
|
|
@ -76,16 +73,11 @@ pub async fn edit_game_settings(uuid: Uuid, new_cluster: Cluster) -> Result<(),
|
|||
let cluster_path = ClusterPath::find_by_uuid(uuid).await?;
|
||||
|
||||
cluster::edit(&cluster_path, |old| {
|
||||
// Game
|
||||
old.force_fullscreen = new_cluster.force_fullscreen;
|
||||
old.resolution = new_cluster.resolution;
|
||||
old.memory = new_cluster.memory;
|
||||
|
||||
// Process
|
||||
old.init_hooks = new_cluster.init_hooks.clone();
|
||||
|
||||
// Java
|
||||
old.java = new_cluster.java.clone();
|
||||
old.init_hooks.clone_from(&new_cluster.init_hooks);
|
||||
old.java.clone_from(&new_cluster.java);
|
||||
|
||||
async move { Ok(()) }
|
||||
})
|
||||
|
|
@ -144,7 +136,7 @@ pub async fn run_cluster(uuid: Uuid) -> Result<DetailedProcess, String> {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_cluster_logs(uuid: Uuid) -> Result<Vec<String>, String> {
|
||||
let cluster = onelauncher::cluster::get_by_uuid(uuid)
|
||||
let cluster = cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or("cluster not found")?;
|
||||
let logs = logger::get_logs(&cluster.cluster_path(), None)
|
||||
|
|
@ -158,7 +150,7 @@ pub async fn get_cluster_logs(uuid: Uuid) -> Result<Vec<String>, String> {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_cluster_log(uuid: Uuid, log_name: String) -> Result<String, String> {
|
||||
let cluster = onelauncher::cluster::get_by_uuid(uuid)
|
||||
let cluster = cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or("cluster not found")?;
|
||||
let log = logger::get_output_by_file(&cluster.cluster_path(), logger::LogType::Info, &log_name)
|
||||
|
|
@ -169,7 +161,7 @@ pub async fn get_cluster_log(uuid: Uuid, log_name: String) -> Result<String, Str
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn upload_log(uuid: Uuid, log_name: String) -> Result<String, String> {
|
||||
let cluster = onelauncher::cluster::get_by_uuid(uuid)
|
||||
let cluster = cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or("cluster not found")?;
|
||||
let log = logger::get_output_by_file(&cluster.cluster_path(), logger::LogType::Info, &log_name)
|
||||
|
|
@ -182,7 +174,7 @@ pub async fn upload_log(uuid: Uuid, log_name: String) -> Result<String, String>
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_screenshots(uuid: Uuid) -> Result<Vec<String>, String> {
|
||||
let cluster = onelauncher::cluster::get_by_uuid(uuid)
|
||||
let cluster = cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or("cluster not found")?;
|
||||
|
||||
|
|
@ -195,7 +187,7 @@ pub async fn get_screenshots(uuid: Uuid) -> Result<Vec<String>, String> {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_worlds(uuid: Uuid) -> Result<Vec<String>, String> {
|
||||
let cluster = onelauncher::cluster::get_by_uuid(uuid)
|
||||
let cluster = cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or("cluster not found")?;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ pub mod commands;
|
|||
pub mod events;
|
||||
pub mod statics;
|
||||
|
||||
#[must_use]
|
||||
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("onelauncher")
|
||||
.setup(|app, _| {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use onelauncher::constants::*;
|
||||
use onelauncher::constants::{NATIVE_ARCH, TARGET_OS, VERSION};
|
||||
use serde::Serialize;
|
||||
use specta::Type;
|
||||
|
||||
|
|
@ -12,8 +12,9 @@ pub struct ProgramInfo {
|
|||
arch: String,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn get_program_info() -> ProgramInfo {
|
||||
let webview_version = tauri::webview_version().unwrap_or("UNKNOWN".into());
|
||||
let webview_version = tauri::webview_version().unwrap_or_else(|_| "UNKNOWN".into());
|
||||
let tauri_version = tauri::VERSION;
|
||||
let dev_build = tauri::is_dev();
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,8 @@ pub async fn install_update(
|
|||
app: tauri::AppHandle,
|
||||
state: tauri::State<'_, State>,
|
||||
) -> Result<(), String> {
|
||||
let lock = match state.install_lock.try_lock() {
|
||||
Ok(lock) => lock,
|
||||
Err(_) => return Err("Update already installing".into()),
|
||||
let Ok(lock) = state.install_lock.try_lock() else {
|
||||
return Err("Update already installing".into());
|
||||
};
|
||||
|
||||
app.emit("updater", UpdateEvent::Installing).ok();
|
||||
|
|
@ -94,6 +93,7 @@ pub async fn install_update(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn plugin<R: Runtime>() -> TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("onelauncher-updater")
|
||||
.on_page_load(|window, _| {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub async fn run_app<F: FnOnce(&tauri::AppHandle<tauri::Wry>) + Send + 'static>(
|
|||
.export(
|
||||
specta_typescript::Typescript::default()
|
||||
.bigint(specta_typescript::BigIntExportBehavior::BigInt)
|
||||
.formatter(crate::ext::specta::formatter),
|
||||
.formatter(ext::specta::formatter),
|
||||
"../../packages/client/src/bindings.ts",
|
||||
)
|
||||
.expect("failed to export debug bindings!");
|
||||
|
|
@ -90,14 +90,15 @@ pub async fn run_app<F: FnOnce(&tauri::AppHandle<tauri::Wry>) + Send + 'static>(
|
|||
tracing::error!("{err}");
|
||||
};
|
||||
|
||||
app.run(|_, _| {})
|
||||
app.run(|_, _| {});
|
||||
}
|
||||
|
||||
fn setup(handle: &tauri::AppHandle) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let win = handle.get_webview_window("main").unwrap();
|
||||
|
||||
tokio::task::spawn(async move {
|
||||
let state = match onelauncher::State::get().await {
|
||||
let state = onelauncher::State::get();
|
||||
let state = match state.await {
|
||||
Ok(state) => state,
|
||||
Err(err) => {
|
||||
tracing::error!("{err}");
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ readme = { workspace = true }
|
|||
homepage = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
onelauncher = { workspace = true, features = [ "cli" ] }
|
||||
tokio = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ async fn main() -> Result<()> {
|
|||
)
|
||||
.await?;
|
||||
|
||||
println!("{:#?}", results);
|
||||
println!("{results:#?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ async fn main() -> onelauncher::Result<()> {
|
|||
// launch_and_authenticate().await?;
|
||||
authenticate_mc().await?;
|
||||
|
||||
Ok(())
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
/// pauline's epic gamer minecraft auth flow
|
||||
|
|
@ -66,7 +66,7 @@ pub async fn modrinth() -> onelauncher::Result<()> {
|
|||
let _state = State::get().await?;
|
||||
let provider = Providers::Modrinth;
|
||||
let result = provider.get("oneconfig").await?;
|
||||
println!("{:#?}", result);
|
||||
println!("{result:#?}");
|
||||
|
||||
// let managed_version = provider
|
||||
// .get_version_for_game_version(&result.id, "1.8.9")
|
||||
|
|
@ -119,7 +119,7 @@ pub async fn launch_and_authenticate() -> onelauncher::Result<()> {
|
|||
println!("clearing clusters");
|
||||
{
|
||||
let c = cluster::list().await?;
|
||||
for cluster in c.into_iter() {
|
||||
for cluster in c {
|
||||
cluster::remove(&cluster.cluster_path()).await?;
|
||||
}
|
||||
}
|
||||
|
|
@ -149,8 +149,8 @@ pub async fn launch_and_authenticate() -> onelauncher::Result<()> {
|
|||
let uuid = c_lock.read().await.uuid;
|
||||
let pid = c_lock.read().await.current_child.read().await.id();
|
||||
|
||||
println!("mc_uuid: {}", uuid);
|
||||
println!("mc_pid: {:?}", pid);
|
||||
println!("mc_uuid: {uuid}");
|
||||
println!("mc_pid: {pid:?}");
|
||||
|
||||
println!("proc_uuid: {:?}", processor::get_running().await?);
|
||||
println!(
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ pub enum PackFileHash {
|
|||
|
||||
impl From<String> for PackFileHash {
|
||||
fn from(s: String) -> Self {
|
||||
return match s.as_str() {
|
||||
match s.as_str() {
|
||||
"sha1" => Self::Sha1,
|
||||
"sha512" => Self::Sha512,
|
||||
_ => Self::Unknown(s),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,26 +64,36 @@ impl fmt::Display for ImportType {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn import_instances(import: ImportType, path: PathBuf) -> crate::Result<Vec<String>> {
|
||||
let instances_path = match import {
|
||||
ImportType::GDLauncher | ImportType::ATLauncher => "instances".to_string(),
|
||||
ImportType::Curseforge => "Instances".to_string(),
|
||||
ImportType::MultiMC => multibased::get_instances_subpath(path.clone().join("multimc.cfg"))
|
||||
.await
|
||||
.unwrap_or_else(|| "instances".to_string()),
|
||||
ImportType::PrismLauncher => {
|
||||
multibased::get_instances_subpath(path.clone().join("prismlauncher.cfg"))
|
||||
.await
|
||||
.unwrap_or_else(|| "instances".to_string())
|
||||
}
|
||||
ImportType::Modrinth => "profiles".to_string(),
|
||||
ImportType::TLauncher => "tinstances".to_string(),
|
||||
ImportType::FTBLauncher => "ftbinstances".to_string(),
|
||||
ImportType::Technic => "tecinstances".to_string(),
|
||||
_ => return Err(anyhow::anyhow!("launcher type unknown, cant import").into()),
|
||||
};
|
||||
impl ImportType {
|
||||
pub async fn get_instances_subpath(&self, path: &Path) -> crate::Result<PathBuf> {
|
||||
Ok(path.join(
|
||||
&(match self {
|
||||
Self::GDLauncher | Self::ATLauncher => "instances".to_string(),
|
||||
Self::Curseforge => "Instances".to_string(),
|
||||
Self::MultiMC => {
|
||||
multibased::get_instances_subpath(path.to_path_buf().join("multimc.cfg"))
|
||||
.await
|
||||
.unwrap_or_else(|| "instances".to_string())
|
||||
}
|
||||
Self::PrismLauncher => {
|
||||
multibased::get_instances_subpath(path.to_path_buf().join("prismlauncher.cfg"))
|
||||
.await
|
||||
.unwrap_or_else(|| "instances".to_string())
|
||||
}
|
||||
Self::Modrinth => "profiles".to_string(),
|
||||
Self::TLauncher => "tinstances".to_string(),
|
||||
Self::FTBLauncher => "ftbinstances".to_string(),
|
||||
Self::Technic => "tecinstances".to_string(),
|
||||
Self::Unknown => {
|
||||
return Err(anyhow::anyhow!("launcher type unknown, cant import").into())
|
||||
}
|
||||
}),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
let instances_dir = path.join(&instances_path);
|
||||
pub async fn import_instances(import: ImportType, path: PathBuf) -> crate::Result<Vec<String>> {
|
||||
let instances_dir = import.get_instances_subpath(&path).await?;
|
||||
let mut instances = Vec::new();
|
||||
let mut dir = io::read_dir(&instances_dir)
|
||||
.await
|
||||
|
|
@ -170,7 +180,6 @@ pub async fn import_instance(
|
|||
#[must_use]
|
||||
pub fn default_launcher_path(r#type: ImportType) -> Option<PathBuf> {
|
||||
let path = match r#type {
|
||||
ImportType::MultiMC => None, // MultiMC data is in it's application directory
|
||||
ImportType::PrismLauncher => Some(dirs::data_dir()?.join("PrismLauncher")),
|
||||
ImportType::ATLauncher => Some(dirs::data_dir()?.join("ATLauncher")),
|
||||
ImportType::GDLauncher => Some(dirs::data_dir()?.join("gdlauncher_next")),
|
||||
|
|
@ -179,7 +188,7 @@ pub fn default_launcher_path(r#type: ImportType) -> Option<PathBuf> {
|
|||
ImportType::FTBLauncher => Some(dirs::data_dir()?.join("FTB")),
|
||||
ImportType::Technic => Some(dirs::data_dir()?.join("Technic")),
|
||||
ImportType::TLauncher => Some(dirs::data_dir()?.join("TLauncher")),
|
||||
ImportType::Unknown => None,
|
||||
ImportType::Unknown | ImportType::MultiMC => None, // MultiMC data is in it's application directory
|
||||
};
|
||||
|
||||
let path = path?;
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ pub async fn get_process_detailed_by_id(uuid: Uuid) -> crate::Result<DetailedPro
|
|||
|
||||
let child = processor
|
||||
.get(uuid)
|
||||
.ok_or(anyhow::anyhow!("process not found"))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?;
|
||||
let child = child.read().await;
|
||||
let pid = child
|
||||
.current_child
|
||||
.read()
|
||||
.await
|
||||
.id()
|
||||
.ok_or(anyhow::anyhow!("process not found"))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?;
|
||||
Ok(DetailedProcess {
|
||||
uuid,
|
||||
user: child.user,
|
||||
|
|
@ -63,14 +63,14 @@ pub async fn get_processes_detailed_by_path(
|
|||
for uuid in uuids {
|
||||
let child = processor
|
||||
.get(uuid)
|
||||
.ok_or(anyhow::anyhow!("process not found"))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?;
|
||||
let child = child.read().await;
|
||||
let pid = child
|
||||
.current_child
|
||||
.read()
|
||||
.await
|
||||
.id()
|
||||
.ok_or(anyhow::anyhow!("process not found"))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?;
|
||||
processes.push(DetailedProcess {
|
||||
uuid,
|
||||
user: child.user,
|
||||
|
|
@ -221,12 +221,12 @@ pub async fn get_pid_by_uuid(uuid: Uuid) -> crate::Result<u32> {
|
|||
let processor = state.processor.read().await;
|
||||
Ok(processor
|
||||
.get(uuid)
|
||||
.ok_or(anyhow::anyhow!("process not found"))?
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?
|
||||
.read()
|
||||
.await
|
||||
.current_child
|
||||
.read()
|
||||
.await
|
||||
.id()
|
||||
.ok_or(anyhow::anyhow!("process not found"))?)
|
||||
.ok_or_else(|| anyhow::anyhow!("process not found"))?)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ pub struct Ingress {
|
|||
pub struct IngressId(Uuid);
|
||||
|
||||
impl Drop for IngressId {
|
||||
#[clippy::has_significant_drop]
|
||||
fn drop(&mut self) {
|
||||
let ingress_uuid = self.0;
|
||||
tokio::spawn(async move {
|
||||
|
|
@ -52,11 +53,10 @@ impl Drop for IngressId {
|
|||
|
||||
#[cfg(feature = "tauri")]
|
||||
{
|
||||
let _ingress_feed_uuid = ingress.ingress_uuid;
|
||||
use tauri::Emitter;
|
||||
let event = ingress.ingress_type.clone();
|
||||
let fraction = ingress.current / ingress.total;
|
||||
|
||||
use tauri::Emitter;
|
||||
let _ = proxy_state.app.emit(
|
||||
"ingress",
|
||||
IngressPayload {
|
||||
|
|
|
|||
|
|
@ -85,8 +85,9 @@ pub async fn edit_ingress(
|
|||
title: &str,
|
||||
) -> crate::Result<()> {
|
||||
let proxy_state = crate::ProxyState::get().await?;
|
||||
let ingress_feeds = proxy_state.ingress_feeds.write();
|
||||
|
||||
if let Some(ingress) = proxy_state.ingress_feeds.write().await.get_mut(&id.0) {
|
||||
if let Some(ingress) = ingress_feeds.await.get_mut(&id.0) {
|
||||
ingress.ingress_type = ingress_type;
|
||||
ingress.total = total;
|
||||
ingress.message = title.to_string();
|
||||
|
|
@ -112,11 +113,9 @@ pub async fn send_ingress(
|
|||
) -> crate::Result<()> {
|
||||
let proxy_state = crate::ProxyState::get().await?;
|
||||
let mut ingress = proxy_state.ingress_feeds.write().await;
|
||||
let ingress = match ingress.get_mut(&key.0) {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
return Err(ProxyError::NoIngressFound(key.0).into());
|
||||
}
|
||||
|
||||
let Some(ingress) = ingress.get_mut(&key.0) else {
|
||||
return Err(ProxyError::NoIngressFound(key.0).into());
|
||||
};
|
||||
|
||||
ingress.current += increment;
|
||||
|
|
@ -125,20 +124,16 @@ pub async fn send_ingress(
|
|||
|
||||
if f64::abs(display - ingress.last_sent) > 0.005 {
|
||||
#[cfg(feature = "cli")]
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
{
|
||||
ingress.cli.set_message(
|
||||
message
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or(ingress.message.clone()),
|
||||
);
|
||||
ingress
|
||||
.cli
|
||||
.set_message(message.map_or_else(|| ingress.message.clone(), ToString::to_string));
|
||||
ingress
|
||||
.cli
|
||||
.set_position((display * CLI_TOTAL_INGRESS as f64).round() as u64);
|
||||
}
|
||||
|
||||
#[cfg(feature = "tauri")]
|
||||
use tauri::Emitter;
|
||||
|
||||
#[cfg(feature = "tauri")]
|
||||
proxy_state
|
||||
.app
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ pub async fn set(settings: Settings) -> crate::Result<()> {
|
|||
}
|
||||
|
||||
/// sets the config and caches directory, this can have side effects.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub async fn set_directory(new: PathBuf) -> crate::Result<()> {
|
||||
tracing::trace!("changing config directory to {}", new.display());
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ pub async fn set_directory(new: PathBuf) -> crate::Result<()> {
|
|||
let old = state_write.directories.config_dir.read().await.clone();
|
||||
|
||||
tracing::trace!("resetting file watcher after changing config directory");
|
||||
let fs_watcher = crate::utils::watcher::initialize_watcher().await?;
|
||||
let fs_watcher = crate::utils::watcher::initialize_watcher()?;
|
||||
state_write.watcher = RwLock::new(fs_watcher);
|
||||
|
||||
tracing::trace!("collecting all config files to be transfered");
|
||||
|
|
@ -167,7 +168,7 @@ pub async fn set_directory(new: PathBuf) -> crate::Result<()> {
|
|||
}
|
||||
|
||||
tracing::trace!("re-resetting file watching system");
|
||||
let mut file_watcher = crate::utils::watcher::initialize_watcher().await?;
|
||||
let mut file_watcher = crate::utils::watcher::initialize_watcher()?;
|
||||
state_write.clusters =
|
||||
RwLock::new(Clusters::initialize(&state_write.directories, &mut file_watcher).await?);
|
||||
state_write.watcher = RwLock::new(file_watcher);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ pub fn minecraft_arguments(
|
|||
asset_index: &str,
|
||||
game_directory: &Path,
|
||||
assets_directory: &Path,
|
||||
version_type: &VersionType,
|
||||
version_type: VersionType,
|
||||
resolution: Resolution,
|
||||
java_arch: &str,
|
||||
) -> crate::Result<Vec<String>> {
|
||||
|
|
@ -196,7 +196,7 @@ fn parse_minecraft_argument(
|
|||
asset_index: &str,
|
||||
game_directory: &Path,
|
||||
assets_directory: &Path,
|
||||
version_type: &VersionType,
|
||||
version_type: VersionType,
|
||||
resolution: Resolution,
|
||||
) -> crate::Result<String> {
|
||||
Ok(argument
|
||||
|
|
|
|||
|
|
@ -325,9 +325,7 @@ pub async fn download_client(
|
|||
let client = version
|
||||
.downloads
|
||||
.get(&ip::api::minecraft::DownloadType::Client)
|
||||
.ok_or(anyhow::anyhow!(
|
||||
"no client downloads exist for {version_id}"
|
||||
))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("no client downloads exist for {version_id}"))?;
|
||||
|
||||
let path = st
|
||||
.directories
|
||||
|
|
|
|||
|
|
@ -76,16 +76,15 @@ pub async fn install_minecraft(
|
|||
|
||||
let version_manifest = metadata.minecraft.clone();
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.ok_or_else(|| anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.versions;
|
||||
|
||||
let version_idx = versions
|
||||
.iter()
|
||||
.position(|g| g.id == cluster.meta.mc_version)
|
||||
.ok_or(anyhow::anyhow!(
|
||||
"invalid minecraft game version {}",
|
||||
cluster.meta.mc_version
|
||||
))?;
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!("invalid minecraft game version {}", cluster.meta.mc_version)
|
||||
})?;
|
||||
|
||||
let version = &versions[version_idx];
|
||||
let updated = version_idx <= versions.iter().position(|g| g.id == "22w16a").unwrap_or(0); // LWJGL patching
|
||||
|
|
@ -271,16 +270,13 @@ pub async fn launch_minecraft(
|
|||
|
||||
let version_manifest = metadata.minecraft.clone();
|
||||
let versions = version_manifest
|
||||
.ok_or(anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.ok_or_else(|| anyhow::anyhow!("couldn't get minecraft manifest"))?
|
||||
.versions;
|
||||
|
||||
let version_index = versions
|
||||
.iter()
|
||||
.position(|it| it.id == cluster.meta.mc_version)
|
||||
.ok_or(anyhow::anyhow!(
|
||||
"invalid game version {}",
|
||||
cluster.meta.mc_version
|
||||
))?;
|
||||
.ok_or_else(|| anyhow::anyhow!("invalid game version {}", cluster.meta.mc_version))?;
|
||||
|
||||
let version = &versions[version_index];
|
||||
let updated = version_index <= versions.iter().position(|x| x.id == "22w16a").unwrap_or(0);
|
||||
|
|
@ -361,7 +357,7 @@ pub async fn launch_minecraft(
|
|||
&version_info.asset_index.id,
|
||||
instance_path,
|
||||
&state.directories.assets_dir().await,
|
||||
&version.type_,
|
||||
version.type_,
|
||||
*resolution,
|
||||
&java_version.arch,
|
||||
)?
|
||||
|
|
@ -382,19 +378,20 @@ pub async fn launch_minecraft(
|
|||
// overrides `options.txt` with our settings: i can't believe it's not yaml
|
||||
if !mc_options.is_empty() {
|
||||
let options_path = instance_path.join("options.txt");
|
||||
let mut options_string = String::new();
|
||||
if options_path.exists() {
|
||||
options_string = io::read_to_string(&options_path).await?;
|
||||
}
|
||||
let mut options_string = if options_path.exists() {
|
||||
io::read_to_string(&options_path).await?
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
for (key, value) in mc_options {
|
||||
let re = regex::Regex::new(&format!(r"(?m)^{}:.*$", regex::escape(key)))?;
|
||||
if !re.is_match(&options_string) {
|
||||
options_string.push_str(&format!("\n{key}:{value}"));
|
||||
} else {
|
||||
if re.is_match(&options_string) {
|
||||
let replaced_string = re
|
||||
.replace_all(&options_string, &format!("{key}:{value}"))
|
||||
.to_string();
|
||||
options_string = replaced_string;
|
||||
} else {
|
||||
options_string.push_str(&format!("\n{key}:{value}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ impl std::str::FromStr for ClusterStage {
|
|||
"installed" => Self::Installed,
|
||||
"downloading" => Self::Downloading,
|
||||
"pack_downloading" => Self::PackDownloading,
|
||||
"not_installed" => Self::NotInstalled,
|
||||
_ => Self::NotInstalled,
|
||||
})
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ impl ClusterPath {
|
|||
pub async fn find_by_uuid(uuid: Uuid) -> crate::Result<Self> {
|
||||
Ok(crate::cluster::get_by_uuid(uuid)
|
||||
.await?
|
||||
.ok_or(anyhow::anyhow!("Cluster does not exist"))?
|
||||
.ok_or_else(|| anyhow::anyhow!("Cluster does not exist"))?
|
||||
.cluster_path())
|
||||
}
|
||||
|
||||
|
|
@ -99,24 +98,27 @@ impl ClusterPath {
|
|||
|
||||
/// Validate the UTF of a cluster path.
|
||||
pub fn validate(&self) -> crate::Result<&Self> {
|
||||
self.0.to_str().ok_or(anyhow::anyhow!(
|
||||
"invalid file path string {}!",
|
||||
self.0.clone().to_string_lossy()
|
||||
))?;
|
||||
self.0.to_str().ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"invalid file path string {}!",
|
||||
self.0.clone().to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Validate the cluster and clone the current [`ClusterPath`].
|
||||
pub async fn cluster_path(&self) -> crate::Result<Self> {
|
||||
if let Some(c) = crate::cluster::get(self).await? {
|
||||
Ok(c.cluster_path())
|
||||
} else {
|
||||
Err(anyhow::anyhow!(
|
||||
"failed to get path of unmanaged or corrupted cluster {}",
|
||||
self.to_string()
|
||||
)
|
||||
.into())
|
||||
}
|
||||
(crate::cluster::get(self).await?).map_or_else(
|
||||
|| {
|
||||
Err(anyhow::anyhow!(
|
||||
"failed to get path of unmanaged or corrupted cluster {}",
|
||||
self.to_string()
|
||||
)
|
||||
.into())
|
||||
},
|
||||
|c| Ok(c.cluster_path()),
|
||||
)
|
||||
}
|
||||
|
||||
/// Create a [`ClusterPath`] from a full [`PathBuf`].
|
||||
|
|
@ -376,7 +378,6 @@ impl Loader {
|
|||
#[must_use]
|
||||
pub fn from_string(val: &str) -> Self {
|
||||
match val {
|
||||
"vanilla" => Self::Vanilla,
|
||||
"forge" => Self::Forge,
|
||||
"fabric" => Self::Fabric,
|
||||
"quilt" => Self::Quilt,
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ impl DiscordRPC {
|
|||
let mut discord_ipc = DiscordIpcClient::new(DISCORD_RPC_CLIENT_ID)
|
||||
.map_err(|e| anyhow::anyhow!("failed to create discord client {}", e))?;
|
||||
|
||||
let connected = if !is_offline {
|
||||
let connected = if is_offline {
|
||||
Arc::new(AtomicBool::new(false))
|
||||
} else {
|
||||
let result = discord_ipc.connect();
|
||||
if result.is_ok() {
|
||||
Arc::new(AtomicBool::new(true))
|
||||
} else {
|
||||
Arc::new(AtomicBool::new(false))
|
||||
}
|
||||
} else {
|
||||
Arc::new(AtomicBool::new(false))
|
||||
};
|
||||
|
||||
let client = Arc::new(RwLock::new(discord_ipc));
|
||||
|
|
@ -92,11 +92,9 @@ impl DiscordRPC {
|
|||
|
||||
/// Attempt to check if we are still in an offline environment.
|
||||
pub async fn retry_online(&self) -> bool {
|
||||
let state = match State::get().await {
|
||||
Ok(s) => s,
|
||||
Err(_) => return false,
|
||||
let Ok(state) = State::get().await else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let offline = state.offline.read().await;
|
||||
if *offline {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -193,11 +193,10 @@ impl Metadata {
|
|||
.await?;
|
||||
}
|
||||
|
||||
if let Some(meta) = metadata {
|
||||
Ok(meta)
|
||||
} else {
|
||||
Err(anyhow::anyhow!("failed to fetch launcher metadata").into())
|
||||
}
|
||||
metadata.map_or_else(
|
||||
|| Err(anyhow::anyhow!("failed to fetch launcher metadata").into()),
|
||||
Ok,
|
||||
)
|
||||
}
|
||||
|
||||
/// Update and backup all available metadata.
|
||||
|
|
|
|||
|
|
@ -38,15 +38,16 @@ impl MinecraftState {
|
|||
.await
|
||||
.ok();
|
||||
|
||||
if let Some(store) = store {
|
||||
Ok(store)
|
||||
} else {
|
||||
Ok(Self {
|
||||
users: HashMap::new(),
|
||||
token: None,
|
||||
default_user: None,
|
||||
})
|
||||
}
|
||||
store.map_or_else(
|
||||
|| {
|
||||
Ok(Self {
|
||||
users: HashMap::new(),
|
||||
token: None,
|
||||
default_user: None,
|
||||
})
|
||||
},
|
||||
Ok,
|
||||
)
|
||||
}
|
||||
|
||||
/// Save the current Minecraft credentials.
|
||||
|
|
@ -141,7 +142,9 @@ impl MinecraftState {
|
|||
redirect_uri: redirect_uri.value.msa_oauth_redirect,
|
||||
}),
|
||||
Err(err) => {
|
||||
if !valid_date {
|
||||
if valid_date {
|
||||
Err(err.into())
|
||||
} else {
|
||||
let (key, token, current_date, _) = self.refresh(Utc::now(), false).await?;
|
||||
let verify = generate_oauth_challenge();
|
||||
let mut hash = sha2::Sha256::new();
|
||||
|
|
@ -157,8 +160,6 @@ impl MinecraftState {
|
|||
session_id,
|
||||
redirect_uri: redirect_uri.value.msa_oauth_redirect,
|
||||
})
|
||||
} else {
|
||||
Err(err.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -877,12 +878,12 @@ async fn send_signed_request<T: serde::de::DeserializeOwned>(
|
|||
step: MinecraftAuthStep,
|
||||
current_date: DateTime<Utc>,
|
||||
) -> Result<SignedRequestResponse<T>, MinecraftAuthError> {
|
||||
use byteorder::WriteBytesExt;
|
||||
let auth = authorization.map_or(Vec::new(), |v| v.as_bytes().to_vec());
|
||||
let body = serde_json::to_vec(&raw_body)
|
||||
.map_err(|source| MinecraftAuthError::SerializeError { step, source })?;
|
||||
let time: u128 = { ((current_date.timestamp() as u128) + 11_644_473_600) * 10_000_000 };
|
||||
|
||||
use byteorder::WriteBytesExt;
|
||||
let mut buffer = Vec::new();
|
||||
buffer
|
||||
.write_u32::<byteorder::BigEndian>(1)
|
||||
|
|
@ -975,7 +976,7 @@ fn get_date_header(headers: &reqwest::header::HeaderMap) -> DateTime<Utc> {
|
|||
.get(reqwest::header::DATE)
|
||||
.and_then(|x| x.to_str().ok())
|
||||
.and_then(|x| DateTime::parse_from_rfc2822(x).ok())
|
||||
.map_or(Utc::now(), |x| x.with_timezone(&Utc))
|
||||
.map_or_else(Utc::now, |x| x.with_timezone(&Utc))
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl State {
|
|||
let settings = Settings::initialize(&Directories::init_settings_file()?).await?;
|
||||
let directories = Directories::initalize(&settings)?;
|
||||
send_ingress(&ingress, 10.0, None).await?;
|
||||
let mut watcher = crate::utils::watcher::initialize_watcher().await?;
|
||||
let mut watcher = crate::utils::watcher::initialize_watcher()?;
|
||||
let fetch_semaphore =
|
||||
FetchSemaphore(RwLock::new(Semaphore::new(settings.max_async_fetches)));
|
||||
let io_semaphore = IoSemaphore(RwLock::new(Semaphore::new(
|
||||
|
|
@ -195,7 +195,8 @@ impl State {
|
|||
/// Updates all data if we are connected to the internet.
|
||||
pub fn update() {
|
||||
tokio::task::spawn(async {
|
||||
if let Ok(state) = Self::get().await {
|
||||
let state = Self::get();
|
||||
if let Ok(state) = state.await {
|
||||
if !*state.offline.read().await {
|
||||
let version_up = Clusters::update_versions();
|
||||
let meta_up = Metadata::update();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ pub enum PackageType {
|
|||
impl PackageType {
|
||||
/// attempt to get a [`PackageType`] from a loader string.
|
||||
#[must_use]
|
||||
pub fn from_loader(loaders: Vec<String>) -> Option<Self> {
|
||||
pub fn from_loader(loaders: &[String]) -> Option<Self> {
|
||||
if loaders
|
||||
.iter()
|
||||
.any(|x| ["fabric", "forge", "quilt"].contains(&&**x))
|
||||
|
|
@ -57,7 +57,7 @@ impl PackageType {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn from_parent(path: PathBuf) -> Option<Self> {
|
||||
pub fn from_parent(path: &Path) -> Option<Self> {
|
||||
let path = path.parent()?.file_name()?;
|
||||
match path.to_str()? {
|
||||
"mods" => Some(Self::Mod),
|
||||
|
|
@ -257,6 +257,7 @@ impl PackagesMeta {
|
|||
#[derive(Debug)]
|
||||
pub struct PackageManager {
|
||||
pub cluster_path: ClusterPath,
|
||||
modpacks: PackagesMeta,
|
||||
mods: PackagesMeta,
|
||||
datapacks: PackagesMeta,
|
||||
resourcepacks: PackagesMeta,
|
||||
|
|
@ -275,6 +276,7 @@ impl PackageManager {
|
|||
pub fn new(cluster_path: ClusterPath) -> Self {
|
||||
Self {
|
||||
cluster_path,
|
||||
modpacks: PackagesMeta::new(PackageType::ModPack),
|
||||
mods: PackagesMeta::new(PackageType::Mod),
|
||||
datapacks: PackagesMeta::new(PackageType::DataPack),
|
||||
resourcepacks: PackagesMeta::new(PackageType::ResourcePack),
|
||||
|
|
@ -296,13 +298,13 @@ impl PackageManager {
|
|||
|
||||
/// Get the `PackagesMeta` for a specific package type. Does not sync.
|
||||
#[must_use]
|
||||
pub fn get(&self, package_type: PackageType) -> &PackagesMeta {
|
||||
pub const fn get(&self, package_type: PackageType) -> &PackagesMeta {
|
||||
match package_type {
|
||||
PackageType::Mod => &self.mods,
|
||||
PackageType::DataPack => &self.datapacks,
|
||||
PackageType::ResourcePack => &self.resourcepacks,
|
||||
PackageType::ShaderPack => &self.shaderpacks,
|
||||
_ => unreachable!(),
|
||||
PackageType::ModPack => &self.modpacks,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -310,10 +312,10 @@ impl PackageManager {
|
|||
fn get_mut(&mut self, package_type: PackageType) -> &mut PackagesMeta {
|
||||
match package_type {
|
||||
PackageType::Mod => &mut self.mods,
|
||||
PackageType::ModPack => &mut self.modpacks,
|
||||
PackageType::DataPack => &mut self.datapacks,
|
||||
PackageType::ResourcePack => &mut self.resourcepacks,
|
||||
PackageType::ShaderPack => &mut self.shaderpacks,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -353,7 +355,7 @@ impl PackageManager {
|
|||
let package_type = package
|
||||
.meta
|
||||
.get_package_type()
|
||||
.unwrap_or(package_type.ok_or(anyhow::anyhow!("no package type"))?);
|
||||
.unwrap_or(package_type.ok_or_else(|| anyhow::anyhow!("no package type"))?);
|
||||
let packages = &mut self.get_mut(package_type).packages;
|
||||
packages.insert(package_path, package);
|
||||
|
||||
|
|
|
|||
|
|
@ -237,16 +237,16 @@ impl ChildType {
|
|||
return Ok(Some(0));
|
||||
}
|
||||
|
||||
let process = system.process(sysinfo::Pid::from_u32(*pid));
|
||||
if let Some(process) = process {
|
||||
if process.status() == sysinfo::ProcessStatus::Run {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(0))
|
||||
}
|
||||
} else {
|
||||
Ok(Some(0))
|
||||
}
|
||||
system.process(sysinfo::Pid::from_u32(*pid)).map_or_else(
|
||||
|| Ok(Some(0)),
|
||||
|process| {
|
||||
if process.status() == sysinfo::ProcessStatus::Run {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(0))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -575,9 +575,9 @@ impl Processor {
|
|||
started_at: Utc
|
||||
.timestamp_opt(cache.start_time as i64, 0)
|
||||
.single()
|
||||
.ok_or(anyhow::anyhow!(
|
||||
"couldn't convert processor cache timestamp to Utc"
|
||||
))?, // TODO: Look into this
|
||||
.ok_or_else(|| {
|
||||
anyhow::anyhow!("couldn't convert processor cache timestamp to Utc")
|
||||
})?, // TODO: Look into this
|
||||
current_child,
|
||||
manager,
|
||||
last_updated,
|
||||
|
|
@ -605,7 +605,8 @@ impl Processor {
|
|||
|
||||
// core main process loop, managed by tokio
|
||||
loop {
|
||||
if let Some(stat) = current_child.write().await.try_wait()? {
|
||||
let value = current_child.write().await.try_wait();
|
||||
if let Some(stat) = value? {
|
||||
exit_status = stat;
|
||||
break;
|
||||
}
|
||||
|
|
@ -655,7 +656,8 @@ impl Processor {
|
|||
});
|
||||
|
||||
tokio::spawn(async {
|
||||
let state = match State::get().await {
|
||||
let state = State::get();
|
||||
let state = match state.await {
|
||||
Ok(state) => state,
|
||||
Err(err) => {
|
||||
tracing::warn!("failed to get state: {}", err);
|
||||
|
|
@ -721,7 +723,8 @@ impl Processor {
|
|||
.await?;
|
||||
|
||||
loop {
|
||||
if let Some(stat) = current_child.write().await.try_wait()? {
|
||||
let value = current_child.write().await.try_wait();
|
||||
if let Some(stat) = value? {
|
||||
exit_status = stat;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer};
|
|||
|
||||
/// Creates and initializes an FS watcher for the `clusters` directory, returning
|
||||
/// the watcher as a [`Debouncer<RecommendedWatcher>`].
|
||||
pub async fn initialize_watcher() -> crate::Result<Debouncer<RecommendedWatcher>> {
|
||||
pub fn initialize_watcher() -> crate::Result<Debouncer<RecommendedWatcher>> {
|
||||
let (mut sender, mut rscv) = channel(1);
|
||||
let watcher = new_debouncer(
|
||||
Duration::from_secs_f32(2.0),
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ fn message(input: &str) -> IResult<&str, &str> {
|
|||
)(input)
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
fn plain_text(input: &str) -> IResult<&str, (Attributes<'_>, &str, &str)> {
|
||||
map(take_until("<"), |text| {
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue