diff --git a/Cargo.toml b/Cargo.toml index 2f5ec3ef1f..0d30b64a01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,6 +263,7 @@ read_zero_byte_vec = "warn" redundant_clone = "warn" redundant_feature_names = "warn" redundant_type_annotations = "warn" +result_large_err = "allow" todo = "warn" too_many_arguments = "allow" uninlined_format_args = "warn" diff --git a/apps/daedalus_client/src/minecraft.rs b/apps/daedalus_client/src/minecraft.rs index a3af06e621..364d7f23c7 100644 --- a/apps/daedalus_client/src/minecraft.rs +++ b/apps/daedalus_client/src/minecraft.rs @@ -144,7 +144,7 @@ pub async fn fetch(semaphore: Arc) -> Result { .chain(existing_versions.into_iter()) .collect::>(); - new_versions.sort_by(|a, b| b.release_time.cmp(&a.release_time)); + new_versions.sort_by_key(|b| std::cmp::Reverse(b.release_time)); // create and upload the new manifest let version_manifest_path = format!( diff --git a/apps/labrinth/src/database/models/project_item.rs b/apps/labrinth/src/database/models/project_item.rs index 0c50729e60..904f799e62 100644 --- a/apps/labrinth/src/database/models/project_item.rs +++ b/apps/labrinth/src/database/models/project_item.rs @@ -861,7 +861,7 @@ impl DBProject { } = loaders_ptypes_games.remove(&project_id).map(|x|x.1).unwrap_or_default(); // Each version is a tuple of (DBVersionId, DateTime) let mut versions = versions.remove(&project_id).map(|x| x.1).unwrap_or_default(); - versions.sort_by(|a, b| a.1.cmp(&b.1)); + versions.sort_by_key(|a| a.1); let mut gallery = mods_gallery.remove(&project_id).map(|x| x.1).unwrap_or_default(); let urls = links.remove(&project_id).map(|x| x.1).unwrap_or_default(); let version_fields = version_fields.remove(&project_id).map(|x| x.1).unwrap_or_default(); @@ -925,7 +925,7 @@ impl DBProject { games, versions: versions.into_iter().map(|x| x.0).collect(), gallery_items: { - gallery.sort_by(|a, b| a.ordering.cmp(&b.ordering)); + gallery.sort_by_key(|a| a.ordering); gallery }, urls, diff --git a/apps/labrinth/src/database/models/thread_item.rs b/apps/labrinth/src/database/models/thread_item.rs index ddded450a7..9796044ddb 100644 --- a/apps/labrinth/src/database/models/thread_item.rs +++ b/apps/labrinth/src/database/models/thread_item.rs @@ -161,7 +161,7 @@ impl DBThread { ) .ok() .unwrap_or_default(); - messages.sort_by(|a, b| a.created.cmp(&b.created)); + messages.sort_by_key(|a| a.created); messages }, members: x.members.unwrap_or_default().into_iter().map(DBUserId).collect(), diff --git a/apps/labrinth/src/main.rs b/apps/labrinth/src/main.rs index 5dd3366b6b..f24a2fb79d 100644 --- a/apps/labrinth/src/main.rs +++ b/apps/labrinth/src/main.rs @@ -1,3 +1,5 @@ +#![recursion_limit = "256"] + use actix_web::dev::Service; use actix_web::middleware::from_fn; use actix_web::{App, HttpServer}; diff --git a/apps/labrinth/src/queue/payouts/mod.rs b/apps/labrinth/src/queue/payouts/mod.rs index 2cb75c25d4..6bee70ff9a 100644 --- a/apps/labrinth/src/queue/payouts/mod.rs +++ b/apps/labrinth/src/queue/payouts/mod.rs @@ -785,7 +785,7 @@ async fn get_tremendous_payout_methods( .into_iter() .map(|x| PayoutDecimal(x.min)) .collect::>(); - values.sort_by(|a, b| a.0.cmp(&b.0)); + values.sort_by_key(|a| a.0); PayoutInterval::Fixed { values } } else if let Some(first) = product.skus.first() { diff --git a/apps/labrinth/src/routes/updates.rs b/apps/labrinth/src/routes/updates.rs index 044b8dc7b5..987d695534 100644 --- a/apps/labrinth/src/routes/updates.rs +++ b/apps/labrinth/src/routes/updates.rs @@ -86,7 +86,7 @@ pub async fn forge_updates( ) .await?; - versions.sort_by(|a, b| b.date_published.cmp(&a.date_published)); + versions.sort_by_key(|b| std::cmp::Reverse(b.date_published)); #[derive(Serialize)] struct ForgeUpdates { diff --git a/apps/labrinth/src/routes/v3/projects.rs b/apps/labrinth/src/routes/v3/projects.rs index 8a204124ec..3c9d978d57 100644 --- a/apps/labrinth/src/routes/v3/projects.rs +++ b/apps/labrinth/src/routes/v3/projects.rs @@ -1359,10 +1359,10 @@ pub async fn dependency_list_internal( ) .await?; - projects.sort_by(|a, b| b.published.cmp(&a.published)); + projects.sort_by_key(|b| std::cmp::Reverse(b.published)); projects.dedup_by(|a, b| a.id == b.id); - versions.sort_by(|a, b| b.date_published.cmp(&a.date_published)); + versions.sort_by_key(|b| std::cmp::Reverse(b.date_published)); versions.dedup_by(|a, b| a.id == b.id); Ok(HttpResponse::Ok().json(DependencyInfo { projects, versions })) diff --git a/apps/labrinth/src/routes/v3/tags.rs b/apps/labrinth/src/routes/v3/tags.rs index a3ac589dc4..175ee06016 100644 --- a/apps/labrinth/src/routes/v3/tags.rs +++ b/apps/labrinth/src/routes/v3/tags.rs @@ -119,7 +119,7 @@ pub async fn loader_list( }) .collect::>(); - results.sort_by(|a, b| a.name.to_lowercase().cmp(&b.name.to_lowercase())); + results.sort_by_key(|a| a.name.to_lowercase()); Ok(HttpResponse::Ok().json(results)) } diff --git a/apps/labrinth/src/routes/v3/users.rs b/apps/labrinth/src/routes/v3/users.rs index 5940450b05..708393cbed 100644 --- a/apps/labrinth/src/routes/v3/users.rs +++ b/apps/labrinth/src/routes/v3/users.rs @@ -799,7 +799,7 @@ pub async fn user_notifications( .map(Into::into) .collect(); - notifications.sort_by(|a, b| b.created.cmp(&a.created)); + notifications.sort_by_key(|b| std::cmp::Reverse(b.created)); Ok(HttpResponse::Ok().json(notifications)) } else { Err(ApiError::NotFound) diff --git a/apps/labrinth/src/search/backend/typesense/mod.rs b/apps/labrinth/src/search/backend/typesense/mod.rs index e7f302b8c7..67ed6d798a 100644 --- a/apps/labrinth/src/search/backend/typesense/mod.rs +++ b/apps/labrinth/src/search/backend/typesense/mod.rs @@ -41,10 +41,11 @@ pub enum Bucketing { BucketSize(u64), } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone, Default)] #[serde(rename_all = "snake_case")] pub enum TextMatchType { MaxScore, + #[default] MaxWeight, SumScore, } @@ -59,12 +60,6 @@ impl TextMatchType { } } -impl Default for TextMatchType { - fn default() -> Self { - Self::MaxWeight - } -} - impl Default for Bucketing { fn default() -> Self { Self::Buckets(5) diff --git a/apps/labrinth/src/search/indexing.rs b/apps/labrinth/src/search/indexing.rs index 85c6408ec2..ff2d734363 100644 --- a/apps/labrinth/src/search/indexing.rs +++ b/apps/labrinth/src/search/indexing.rs @@ -547,8 +547,8 @@ async fn index_versions( } let all_version_ids = versions - .iter() - .flat_map(|(_, version_ids)| version_ids.iter()) + .values() + .flat_map(|version_ids| version_ids.iter()) .map(|(version_id, _)| version_id.0) .collect::>(); diff --git a/apps/labrinth/src/util/webhook.rs b/apps/labrinth/src/util/webhook.rs index e27b9e8e72..fd1237746c 100644 --- a/apps/labrinth/src/util/webhook.rs +++ b/apps/labrinth/src/util/webhook.rs @@ -509,10 +509,10 @@ fn get_gv_range( mut all_game_versions: Vec, ) -> Vec { // both -> least to greatest - game_versions.sort_by(|a, b| a.created.cmp(&b.created)); + game_versions.sort_by_key(|a| a.created); game_versions.dedup_by(|a, b| a.version == b.version); - all_game_versions.sort_by(|a, b| a.created.cmp(&b.created)); + all_game_versions.sort_by_key(|a| a.created); let all_releases = all_game_versions .iter() diff --git a/docker-compose.yml b/docker-compose.yml index a2979181fd..f64fe828a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,167 +51,6 @@ services: interval: 3s timeout: 5s retries: 3 - elasticsearch-certs: - image: elasticsearch:9.3.0 - container_name: labrinth-elasticsearch-certs - user: '0' - networks: - - elasticsearch-mesh - restart: 'no' - volumes: - - elasticsearch-certs:/usr/share/elasticsearch/config/certs - command: | - bash -c ' - set -euo pipefail - if [ ! -s config/certs/ca/ca.crt ] || [ ! -s config/certs/elasticsearch0/elasticsearch0.crt ] || [ ! -s config/certs/elasticsearch1/elasticsearch1.crt ] || [ ! -s config/certs/elasticsearch2/elasticsearch2.crt ]; then - rm -rf config/certs/* - printf "%s\n" \ - "instances:" \ - " - name: elasticsearch0" \ - " dns:" \ - " - elasticsearch0" \ - " - localhost" \ - " ip:" \ - " - 127.0.0.1" \ - " - name: elasticsearch1" \ - " dns:" \ - " - elasticsearch1" \ - " - localhost" \ - " ip:" \ - " - 127.0.0.1" \ - " - name: elasticsearch2" \ - " dns:" \ - " - elasticsearch2" \ - " - localhost" \ - " ip:" \ - " - 127.0.0.1" \ - > config/certs/instances.yml - bin/elasticsearch-certutil ca --silent --pem --out config/certs/ca.zip - unzip config/certs/ca.zip -d config/certs - bin/elasticsearch-certutil cert --silent --pem --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key --out config/certs/certs.zip - unzip config/certs/certs.zip -d config/certs - fi - chown -R 1000:0 config/certs - find config/certs -type d -exec chmod 750 {} \; - find config/certs -type f -exec chmod 640 {} \; - echo "Set up certificates" - ' - elasticsearch0: - image: elasticsearch:9.3.0 - container_name: labrinth-elasticsearch0 - networks: - - elasticsearch-mesh - restart: on-failure - depends_on: - elasticsearch-certs: - condition: service_completed_successfully - ports: - - '127.0.0.1:9200:9200' - volumes: - - elasticsearch0-data:/usr/share/elasticsearch/data - - elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro - environment: - - logger.level=WARN - - node.name=elasticsearch0 - - cluster.name=labrinth - - cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2 - - discovery.seed_hosts=elasticsearch1,elasticsearch2 - - bootstrap.memory_lock=false - # auth - - xpack.security.enabled=true - - xpack.security.transport.ssl.enabled=true - - xpack.security.transport.ssl.verification_mode=certificate - - xpack.security.transport.ssl.key=certs/elasticsearch0/elasticsearch0.key - - xpack.security.transport.ssl.certificate=certs/elasticsearch0/elasticsearch0.crt - - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt - - ELASTIC_USERNAME=elastic - - ELASTIC_PASSWORD=elastic - mem_limit: 1g - healthcheck: - test: - [ - 'CMD-SHELL', - 'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""', - ] - interval: 10s - timeout: 5s - retries: 10 - elasticsearch1: - image: elasticsearch:9.3.0 - container_name: labrinth-elasticsearch1 - networks: - - elasticsearch-mesh - restart: on-failure - depends_on: - elasticsearch-certs: - condition: service_completed_successfully - volumes: - - elasticsearch1-data:/usr/share/elasticsearch/data - - elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro - environment: - - logger.level=WARN - - node.name=elasticsearch1 - - cluster.name=labrinth - - cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2 - - discovery.seed_hosts=elasticsearch0,elasticsearch2 - - bootstrap.memory_lock=false - # auth - - xpack.security.enabled=true - - xpack.security.transport.ssl.enabled=true - - xpack.security.transport.ssl.verification_mode=certificate - - xpack.security.transport.ssl.key=certs/elasticsearch1/elasticsearch1.key - - xpack.security.transport.ssl.certificate=certs/elasticsearch1/elasticsearch1.crt - - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt - - ELASTIC_USERNAME=elastic - - ELASTIC_PASSWORD=elastic - mem_limit: 1g - healthcheck: - test: - [ - 'CMD-SHELL', - 'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""', - ] - interval: 10s - timeout: 5s - retries: 10 - elasticsearch2: - image: elasticsearch:9.3.0 - container_name: labrinth-elasticsearch2 - networks: - - elasticsearch-mesh - restart: on-failure - depends_on: - elasticsearch-certs: - condition: service_completed_successfully - volumes: - - elasticsearch2-data:/usr/share/elasticsearch/data - - elasticsearch-certs:/usr/share/elasticsearch/config/certs:ro - environment: - - logger.level=WARN - - node.name=elasticsearch2 - - cluster.name=labrinth - - cluster.initial_master_nodes=elasticsearch0,elasticsearch1,elasticsearch2 - - discovery.seed_hosts=elasticsearch0,elasticsearch1 - - bootstrap.memory_lock=false - # auth - - xpack.security.enabled=true - - xpack.security.transport.ssl.enabled=true - - xpack.security.transport.ssl.verification_mode=certificate - - xpack.security.transport.ssl.key=certs/elasticsearch2/elasticsearch2.key - - xpack.security.transport.ssl.certificate=certs/elasticsearch2/elasticsearch2.crt - - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt - - ELASTIC_USERNAME=elastic - - ELASTIC_PASSWORD=elastic - mem_limit: 1g - healthcheck: - test: - [ - 'CMD-SHELL', - 'curl -s -u elastic:elastic http://localhost:9200/_cluster/health | grep -qE "\"status\":\"(yellow|green)\""', - ] - interval: 10s - timeout: 5s - retries: 10 redis: image: redis:alpine container_name: labrinth-redis diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 2ce412d5ad..f92020c653 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.90.0" +channel = "1.95.0" profile = "default"