You've already forked AstralRinth
forked from didirus/AstralRinth
Fix clippy issues
This commit is contained in:
37
.github/workflows/lint.yml
vendored
Normal file
37
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Clippy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
- name: Cache build artifacts
|
||||||
|
id: cache-build
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: target/**
|
||||||
|
key: ${{ runner.os }}-build-cache
|
||||||
|
- name: Theseus Clippy
|
||||||
|
uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --bin theseus
|
||||||
|
- name: Theseus CLI Clippy
|
||||||
|
uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --bin theseus_cli
|
||||||
13
COPYING.md
Normal file
13
COPYING.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Copying
|
||||||
|
|
||||||
|
The source code of the knossos repository is licensed under the GNU Affero General Public License, Version 3 only, which is provided in the file [LICENSE](./LICENSE). However, some files listed below are licensed under a different license.
|
||||||
|
|
||||||
|
## Modrinth logo
|
||||||
|
|
||||||
|
Any files depicting the Modrinth branding, including the wrench-in-labyrinth logo, the landing image, and variations thereof, are licensed as follows:
|
||||||
|
|
||||||
|
> All rights reserved. © 2020-2023 Rinth, Inc.
|
||||||
|
|
||||||
|
This includes, but may not be limited to, the following files:
|
||||||
|
|
||||||
|
- theseus_gui/src-tauri/icons
|
||||||
@@ -88,7 +88,7 @@ pub async fn has_user(user: uuid::Uuid) -> crate::Result<bool> {
|
|||||||
let state = State::get().await?;
|
let state = State::get().await?;
|
||||||
let users = state.users.read().await;
|
let users = state.users.read().await;
|
||||||
|
|
||||||
Ok(users.contains(user)?)
|
users.contains(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a copy of the list of all user credentials
|
/// Get a copy of the list of all user credentials
|
||||||
|
|||||||
@@ -68,12 +68,7 @@ pub async fn is_managed(profile: &Path) -> crate::Result<bool> {
|
|||||||
pub async fn is_loaded(profile: &Path) -> crate::Result<bool> {
|
pub async fn is_loaded(profile: &Path) -> crate::Result<bool> {
|
||||||
let state = State::get().await?;
|
let state = State::get().await?;
|
||||||
let profiles = state.profiles.read().await;
|
let profiles = state.profiles.read().await;
|
||||||
Ok(profiles
|
Ok(profiles.0.get(profile).and_then(Option::as_ref).is_some())
|
||||||
.0
|
|
||||||
.get(profile)
|
|
||||||
.map(Option::as_ref)
|
|
||||||
.flatten()
|
|
||||||
.is_some())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Edit a profile using a given asynchronous closure
|
/// Edit a profile using a given asynchronous closure
|
||||||
@@ -138,8 +133,8 @@ pub async fn run(
|
|||||||
})?;
|
})?;
|
||||||
let version_info = d::minecraft::fetch_version_info(version).await?;
|
let version_info = d::minecraft::fetch_version_info(version).await?;
|
||||||
|
|
||||||
let ref pre_launch_hooks =
|
let pre_launch_hooks =
|
||||||
profile.hooks.as_ref().unwrap_or(&settings.hooks).pre_launch;
|
&profile.hooks.as_ref().unwrap_or(&settings.hooks).pre_launch;
|
||||||
for hook in pre_launch_hooks.iter() {
|
for hook in pre_launch_hooks.iter() {
|
||||||
// TODO: hook parameters
|
// TODO: hook parameters
|
||||||
let mut cmd = hook.split(' ');
|
let mut cmd = hook.split(' ');
|
||||||
@@ -190,7 +185,7 @@ pub async fn run(
|
|||||||
.as_error());
|
.as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
let ref java_args = profile
|
let java_args = profile
|
||||||
.java
|
.java
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|it| it.extra_arguments.as_ref())
|
.and_then(|it| it.extra_arguments.as_ref())
|
||||||
@@ -201,18 +196,18 @@ pub async fn run(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(&settings.hooks.wrapper, |it| &it.wrapper);
|
.map_or(&settings.hooks.wrapper, |it| &it.wrapper);
|
||||||
|
|
||||||
let ref memory = profile.memory.unwrap_or(settings.memory);
|
let memory = profile.memory.unwrap_or(settings.memory);
|
||||||
let ref resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
let resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
||||||
|
|
||||||
crate::launcher::launch_minecraft(
|
crate::launcher::launch_minecraft(
|
||||||
&profile.metadata.game_version,
|
&profile.metadata.game_version,
|
||||||
&profile.metadata.loader_version,
|
&profile.metadata.loader_version,
|
||||||
&profile.path,
|
&profile.path,
|
||||||
&java_install,
|
java_install,
|
||||||
&java_args,
|
java_args,
|
||||||
&wrapper,
|
wrapper,
|
||||||
memory,
|
&memory,
|
||||||
resolution,
|
&resolution,
|
||||||
credentials,
|
credentials,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub fn get_class_paths_jar<T: AsRef<str>>(
|
|||||||
pub fn get_lib_path(libraries_path: &Path, lib: &str) -> crate::Result<String> {
|
pub fn get_lib_path(libraries_path: &Path, lib: &str) -> crate::Result<String> {
|
||||||
let mut path = libraries_path.to_path_buf();
|
let mut path = libraries_path.to_path_buf();
|
||||||
|
|
||||||
path.push(get_path_from_artifact(lib.as_ref())?);
|
path.push(get_path_from_artifact(lib)?);
|
||||||
|
|
||||||
let path = &path.canonicalize().map_err(|_| {
|
let path = &path.canonicalize().map_err(|_| {
|
||||||
crate::ErrorKind::LauncherError(format!(
|
crate::ErrorKind::LauncherError(format!(
|
||||||
@@ -164,8 +164,7 @@ fn parse_jvm_argument(
|
|||||||
))
|
))
|
||||||
.as_error()
|
.as_error()
|
||||||
})?
|
})?
|
||||||
.to_string_lossy()
|
.to_string_lossy(),
|
||||||
.to_string(),
|
|
||||||
)
|
)
|
||||||
.replace("${classpath_separator}", classpath_separator())
|
.replace("${classpath_separator}", classpath_separator())
|
||||||
.replace("${launcher_name}", "theseus")
|
.replace("${launcher_name}", "theseus")
|
||||||
@@ -219,7 +218,6 @@ pub fn get_minecraft_arguments(
|
|||||||
resolution,
|
resolution,
|
||||||
)?
|
)?
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.into_iter()
|
|
||||||
.map(|x| x.to_string())
|
.map(|x| x.to_string())
|
||||||
.collect())
|
.collect())
|
||||||
} else {
|
} else {
|
||||||
@@ -260,8 +258,7 @@ fn parse_minecraft_argument(
|
|||||||
))
|
))
|
||||||
.as_error()
|
.as_error()
|
||||||
})?
|
})?
|
||||||
.to_string_lossy()
|
.to_string_lossy(),
|
||||||
.to_owned(),
|
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"${assets_root}",
|
"${assets_root}",
|
||||||
@@ -274,8 +271,7 @@ fn parse_minecraft_argument(
|
|||||||
))
|
))
|
||||||
.as_error()
|
.as_error()
|
||||||
})?
|
})?
|
||||||
.to_string_lossy()
|
.to_string_lossy(),
|
||||||
.to_owned(),
|
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"${game_assets}",
|
"${game_assets}",
|
||||||
@@ -288,8 +284,7 @@ fn parse_minecraft_argument(
|
|||||||
))
|
))
|
||||||
.as_error()
|
.as_error()
|
||||||
})?
|
})?
|
||||||
.to_string_lossy()
|
.to_string_lossy(),
|
||||||
.to_owned(),
|
|
||||||
)
|
)
|
||||||
.replace("${version_type}", version_type.as_str())
|
.replace("${version_type}", version_type.as_str())
|
||||||
.replace("${resolution_width}", &resolution.0.to_string())
|
.replace("${resolution_width}", &resolution.0.to_string())
|
||||||
@@ -366,7 +361,7 @@ pub fn get_processor_arguments<T: AsRef<str>>(
|
|||||||
pub async fn get_processor_main_class(
|
pub async fn get_processor_main_class(
|
||||||
path: String,
|
path: String,
|
||||||
) -> crate::Result<Option<String>> {
|
) -> crate::Result<Option<String>> {
|
||||||
Ok(tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
let zipfile = std::fs::File::open(&path)?;
|
let zipfile = std::fs::File::open(&path)?;
|
||||||
let mut archive = zip::ZipArchive::new(zipfile).map_err(|_| {
|
let mut archive = zip::ZipArchive::new(zipfile).map_err(|_| {
|
||||||
crate::ErrorKind::LauncherError(format!(
|
crate::ErrorKind::LauncherError(format!(
|
||||||
@@ -400,5 +395,5 @@ pub async fn get_processor_main_class(
|
|||||||
Ok::<Option<String>, crate::Error>(None)
|
Ok::<Option<String>, crate::Error>(None)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap()?)
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ use async_tungstenite as ws;
|
|||||||
use bincode::{Decode, Encode};
|
use bincode::{Decode, Encode};
|
||||||
use chrono::{prelude::*, Duration};
|
use chrono::{prelude::*, Duration};
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use once_cell::sync::*;
|
use lazy_static::lazy_static;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub const HYDRA_URL: Lazy<Url> =
|
lazy_static! {
|
||||||
Lazy::new(|| Url::parse("https://hydra.modrinth.com").unwrap());
|
static ref HYDRA_URL: Url =
|
||||||
|
Url::parse("https://hydra.modrinth.com").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// Socket messages
|
// Socket messages
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -65,7 +67,7 @@ pub struct HydraAuthFlow<S: AsyncRead + AsyncWrite + Unpin> {
|
|||||||
impl HydraAuthFlow<ws::tokio::ConnectStream> {
|
impl HydraAuthFlow<ws::tokio::ConnectStream> {
|
||||||
pub async fn new() -> crate::Result<Self> {
|
pub async fn new() -> crate::Result<Self> {
|
||||||
let sock_url = wrap_ref_builder!(
|
let sock_url = wrap_ref_builder!(
|
||||||
it = HYDRA_URL =>
|
it = HYDRA_URL.clone() =>
|
||||||
{ it.set_scheme("wss").ok() }
|
{ it.set_scheme("wss").ok() }
|
||||||
);
|
);
|
||||||
let (socket, _) = ws::tokio::connect_async(sock_url.clone()).await?;
|
let (socket, _) = ws::tokio::connect_async(sock_url.clone()).await?;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ pub async fn download_client(
|
|||||||
st: &State,
|
st: &State,
|
||||||
version_info: &GameVersionInfo,
|
version_info: &GameVersionInfo,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
let ref version = version_info.id;
|
let version = &version_info.id;
|
||||||
log::debug!("Locating client for version {version}");
|
log::debug!("Locating client for version {version}");
|
||||||
let client_download = version_info
|
let client_download = version_info
|
||||||
.downloads
|
.downloads
|
||||||
@@ -143,7 +143,7 @@ pub async fn download_assets(
|
|||||||
stream::iter(index.objects.iter())
|
stream::iter(index.objects.iter())
|
||||||
.map(Ok::<(&String, &Asset), crate::Error>)
|
.map(Ok::<(&String, &Asset), crate::Error>)
|
||||||
.try_for_each_concurrent(None, |(name, asset)| async move {
|
.try_for_each_concurrent(None, |(name, asset)| async move {
|
||||||
let ref hash = asset.hash;
|
let hash = &asset.hash;
|
||||||
let resource_path = st.directories.object_dir(hash);
|
let resource_path = st.directories.object_dir(hash);
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://resources.download.minecraft.net/{sub_hash}/{hash}",
|
"https://resources.download.minecraft.net/{sub_hash}/{hash}",
|
||||||
@@ -158,7 +158,7 @@ pub async fn download_assets(
|
|||||||
let resource = fetch_cell
|
let resource = fetch_cell
|
||||||
.get_or_try_init(|| fetch(&url, Some(hash), &permit))
|
.get_or_try_init(|| fetch(&url, Some(hash), &permit))
|
||||||
.await?;
|
.await?;
|
||||||
write(&resource_path, &resource, &permit).await?;
|
write(&resource_path, resource, &permit).await?;
|
||||||
log::info!("Fetched asset with hash {hash}");
|
log::info!("Fetched asset with hash {hash}");
|
||||||
}
|
}
|
||||||
Ok::<_, crate::Error>(())
|
Ok::<_, crate::Error>(())
|
||||||
@@ -172,7 +172,7 @@ pub async fn download_assets(
|
|||||||
let resource_path = st.directories.legacy_assets_dir().join(
|
let resource_path = st.directories.legacy_assets_dir().join(
|
||||||
name.replace('/', &String::from(std::path::MAIN_SEPARATOR))
|
name.replace('/', &String::from(std::path::MAIN_SEPARATOR))
|
||||||
);
|
);
|
||||||
write(&resource_path, &resource, &permit).await?;
|
write(&resource_path, resource, &permit).await?;
|
||||||
log::info!("Fetched legacy asset with hash {hash}");
|
log::info!("Fetched legacy asset with hash {hash}");
|
||||||
}
|
}
|
||||||
Ok::<_, crate::Error>(())
|
Ok::<_, crate::Error>(())
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ macro_rules! processor_rules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
#[tracing::instrument(skip_all, fields(path = ?instance_path))]
|
#[tracing::instrument(skip_all, fields(path = ?instance_path))]
|
||||||
pub async fn launch_minecraft(
|
pub async fn launch_minecraft(
|
||||||
game_version: &str,
|
game_version: &str,
|
||||||
@@ -75,7 +76,7 @@ pub async fn launch_minecraft(
|
|||||||
|
|
||||||
let mut version_info = download::download_version_info(
|
let mut version_info = download::download_version_info(
|
||||||
&state,
|
&state,
|
||||||
&version,
|
version,
|
||||||
loader_version.as_ref(),
|
loader_version.as_ref(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ impl Metadata {
|
|||||||
|
|
||||||
if let Some(ref meta_bin) = db.get(METADATA_DB_FIELD)? {
|
if let Some(ref meta_bin) = db.get(METADATA_DB_FIELD)? {
|
||||||
match bincode::decode_from_slice::<Self, _>(
|
match bincode::decode_from_slice::<Self, _>(
|
||||||
&meta_bin,
|
meta_bin,
|
||||||
*BINCODE_CONFIG,
|
*BINCODE_CONFIG,
|
||||||
) {
|
) {
|
||||||
Ok((meta, _)) => metadata = Some(meta),
|
Ok((meta, _)) => metadata = Some(meta),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub(crate) struct Profiles(pub HashMap<PathBuf, Option<Profile>>);
|
|||||||
|
|
||||||
// TODO: possibly add defaults to some of these values
|
// TODO: possibly add defaults to some of these values
|
||||||
pub const CURRENT_FORMAT_VERSION: u32 = 1;
|
pub const CURRENT_FORMAT_VERSION: u32 = 1;
|
||||||
pub const SUPPORTED_ICON_FORMATS: &[&'static str] = &[
|
pub const SUPPORTED_ICON_FORMATS: &[&str] = &[
|
||||||
"bmp", "gif", "jpeg", "jpg", "jpe", "png", "svg", "svgz", "webp", "rgb",
|
"bmp", "gif", "jpeg", "jpg", "jpe", "png", "svg", "svgz", "webp", "rgb",
|
||||||
"mp4",
|
"mp4",
|
||||||
];
|
];
|
||||||
@@ -54,26 +54,23 @@ pub struct ProfileMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Quilt?
|
// TODO: Quilt?
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Deserialize, Serialize)]
|
#[derive(
|
||||||
|
Debug, Eq, PartialEq, Clone, Copy, Deserialize, Serialize, Default,
|
||||||
|
)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum ModLoader {
|
pub enum ModLoader {
|
||||||
|
#[default]
|
||||||
Vanilla,
|
Vanilla,
|
||||||
Forge,
|
Forge,
|
||||||
Fabric,
|
Fabric,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ModLoader {
|
|
||||||
fn default() -> Self {
|
|
||||||
ModLoader::Vanilla
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for ModLoader {
|
impl std::fmt::Display for ModLoader {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.write_str(match self {
|
f.write_str(match *self {
|
||||||
&Self::Vanilla => "Vanilla",
|
Self::Vanilla => "Vanilla",
|
||||||
&Self::Forge => "Forge",
|
Self::Forge => "Forge",
|
||||||
&Self::Fabric => "Fabric",
|
Self::Fabric => "Fabric",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +234,7 @@ impl Profiles {
|
|||||||
// project path, parent profile path
|
// project path, parent profile path
|
||||||
let mut files: HashMap<PathBuf, PathBuf> = HashMap::new();
|
let mut files: HashMap<PathBuf, PathBuf> = HashMap::new();
|
||||||
{
|
{
|
||||||
for (profile_path, _profile_optZA) in profiles.iter() {
|
for (profile_path, _profile_opt) in profiles.iter() {
|
||||||
let mut read_paths = |path: &str| {
|
let mut read_paths = |path: &str| {
|
||||||
for path in std::fs::read_dir(profile_path.join(path))? {
|
for path in std::fs::read_dir(profile_path.join(path))? {
|
||||||
files.insert(path?.path(), profile_path.clone());
|
files.insert(path?.path(), profile_path.clone());
|
||||||
@@ -252,17 +249,15 @@ impl Profiles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let inferred = super::projects::infer_data_from_files(
|
let inferred = super::projects::infer_data_from_files(
|
||||||
files.keys().into_iter().cloned().collect(),
|
files.keys().cloned().collect(),
|
||||||
dirs.caches_dir(),
|
dirs.caches_dir(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for (key, value) in inferred {
|
for (key, value) in inferred {
|
||||||
if let Some(profile_path) = files.get(&key) {
|
if let Some(profile_path) = files.get(&key) {
|
||||||
if let Some(profile) = profiles.get_mut(profile_path) {
|
if let Some(Some(profile)) = profiles.get_mut(profile_path) {
|
||||||
if let Some(profile) = profile {
|
profile.projects.insert(key, value);
|
||||||
profile.projects.insert(key, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub struct ModrinthProject {
|
|||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
#[serde(tag = "type", rename_all = "snake_case")]
|
#[serde(tag = "type", rename_all = "snake_case")]
|
||||||
pub enum ProjectMetadata {
|
pub enum ProjectMetadata {
|
||||||
Modrinth(ModrinthProject),
|
Modrinth(Box<ModrinthProject>),
|
||||||
Inferred {
|
Inferred {
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
@@ -126,7 +126,9 @@ pub async fn infer_data_from_files(
|
|||||||
Project {
|
Project {
|
||||||
sha512: hash,
|
sha512: hash,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
metadata: ProjectMetadata::Modrinth(project.clone()),
|
metadata: ProjectMetadata::Modrinth(Box::new(
|
||||||
|
project.clone(),
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
@@ -342,10 +344,7 @@ pub async fn infer_data_from_files(
|
|||||||
if file.read_to_string(&mut file_str).is_ok() {
|
if file.read_to_string(&mut file_str).is_ok() {
|
||||||
if let Ok(pack) = serde_json::from_str::<QuiltMod>(&file_str) {
|
if let Ok(pack) = serde_json::from_str::<QuiltMod>(&file_str) {
|
||||||
let icon = read_icon_from_file(
|
let icon = read_icon_from_file(
|
||||||
pack.metadata
|
pack.metadata.as_ref().and_then(|x| x.icon.clone()),
|
||||||
.as_ref()
|
|
||||||
.map(|x| x.icon.clone())
|
|
||||||
.flatten(),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
return_projects.insert(
|
return_projects.insert(
|
||||||
@@ -357,15 +356,13 @@ pub async fn infer_data_from_files(
|
|||||||
title: Some(
|
title: Some(
|
||||||
pack.metadata
|
pack.metadata
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| x.name.clone())
|
.and_then(|x| x.name.clone())
|
||||||
.flatten()
|
|
||||||
.unwrap_or(pack.id),
|
.unwrap_or(pack.id),
|
||||||
),
|
),
|
||||||
description: pack
|
description: pack
|
||||||
.metadata
|
.metadata
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| x.description.clone())
|
.and_then(|x| x.description.clone()),
|
||||||
.flatten(),
|
|
||||||
authors: pack
|
authors: pack
|
||||||
.metadata
|
.metadata
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ impl Default for WindowSize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Game initialization hooks
|
/// Game initialization hooks
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Hooks {
|
pub struct Hooks {
|
||||||
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
||||||
@@ -113,13 +113,3 @@ pub struct Hooks {
|
|||||||
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
||||||
pub post_exit: HashSet<String>,
|
pub post_exit: HashSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Hooks {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
pre_launch: HashSet::<String>::new(),
|
|
||||||
wrapper: None,
|
|
||||||
post_exit: HashSet::<String>::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub async fn fetch_mirrors(
|
|||||||
let _permits = sem.acquire_many(permits).await.unwrap();
|
let _permits = sem.acquire_many(permits).await.unwrap();
|
||||||
let sem = Arc::new(Semaphore::new(permits.try_into().unwrap()));
|
let sem = Arc::new(Semaphore::new(permits.try_into().unwrap()));
|
||||||
|
|
||||||
future::select_ok(urls.into_iter().map(|url| {
|
future::select_ok(urls.iter().map(|url| {
|
||||||
let sha1 = sha1.map(String::from);
|
let sha1 = sha1.map(String::from);
|
||||||
let url = String::from(*url);
|
let url = String::from(*url);
|
||||||
let sem = Arc::clone(&sem);
|
let sem = Arc::clone(&sem);
|
||||||
|
|||||||
@@ -185,11 +185,11 @@ pub fn get_all_jre_path() -> Result<HashSet<JavaVersion>, JREError> {
|
|||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const JAVA_BIN: &'static str = "java.exe";
|
const JAVA_BIN: &str = "java.exe";
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const JAVA_BIN: &'static str = "java";
|
const JAVA_BIN: &str = "java";
|
||||||
|
|
||||||
// For example filepath 'path', attempt to resolve it and get a Java version at this path
|
// For example filepath 'path', attempt to resolve it and get a Java version at this path
|
||||||
// If no such path exists, or no such valid java at this path exists, returns None
|
// If no such path exists, or no such valid java at this path exists, returns None
|
||||||
|
|||||||
@@ -31,11 +31,7 @@ pub fn os_rule(rule: &OsRule) -> bool {
|
|||||||
let mut rule_match = true;
|
let mut rule_match = true;
|
||||||
|
|
||||||
if let Some(ref arch) = rule.arch {
|
if let Some(ref arch) = rule.arch {
|
||||||
rule_match &= match arch.as_str() {
|
rule_match &= !matches!(arch.as_str(), "x86" | "arm");
|
||||||
"x86" => cfg!(any(target_arch = "x86", target_arch = "x86_64")),
|
|
||||||
"arm" => cfg!(target_arch = "arm"),
|
|
||||||
_ => true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = &rule.name {
|
if let Some(name) = &rule.name {
|
||||||
|
|||||||
@@ -26,7 +26,13 @@
|
|||||||
"depends": []
|
"depends": []
|
||||||
},
|
},
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"icon": ["icons/favicon.ico"],
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
"identifier": "com.modrinth.theseus",
|
"identifier": "com.modrinth.theseus",
|
||||||
"longDescription": "",
|
"longDescription": "",
|
||||||
"macOS": {
|
"macOS": {
|
||||||
|
|||||||
Reference in New Issue
Block a user