Merge pull request #4 from modrinth/many-fixes-again

Fix forge syncing not working
This commit is contained in:
Geometrically 2023-04-05 12:40:17 -07:00 committed by GitHub
commit fd19bb7cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 20 deletions

2
.env
View File

@ -1,4 +1,4 @@
RUST_LOG=info,error
RUST_LOG=info
BASE_URL=https://modrinth-cdn-staging.nyc3.digitaloceanspaces.com

View File

@ -1,7 +1,21 @@
FROM rust:1.68.2
COPY ./ ./
FROM rust:1.68.2 as build
ENV PKG_CONFIG_ALLOW_CROSS=1
WORKDIR /usr/src/daedalus
COPY . .
RUN cargo build --release
CMD ["./target/release/daedalus_client"]
FROM debian:bullseye-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
COPY --from=build /usr/src/daedalus/target/release/daedalus_client /daedalus/daedalus_client
WORKDIR /daedalus_client
CMD /daedalus/daedalus_client

View File

@ -1,6 +1,6 @@
[package]
name = "daedalus"
version = "0.1.18"
version = "0.1.19"
authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018"
license = "MIT"

View File

@ -131,7 +131,7 @@ pub fn merge_partial_version(
asset_index: merge.asset_index,
assets: merge.assets,
downloads: merge.downloads,
id: merge.id,
id: partial.id.replace(DUMMY_REPLACE_STRING, &merge_id),
java_version: merge.java_version,
libraries: partial
.libraries

View File

@ -1,6 +1,6 @@
[package]
name = "daedalus_client"
version = "0.1.18"
version = "0.1.19"
authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018"

View File

@ -82,6 +82,7 @@ pub async fn retrieve_data(
visited_artifacts_mutex.lock().await;
if visited_assets.contains(&lib.name) {
lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING);
lib.url = Some(format_url("maven/"));
return Ok(lib);
@ -92,7 +93,6 @@ pub async fn retrieve_data(
if lib.name.contains(DUMMY_GAME_VERSION) {
lib.name = lib.name.replace(DUMMY_GAME_VERSION, DUMMY_REPLACE_STRING);
lib.url = Some(format_url("maven/"));
futures::future::try_join_all(list.game.clone().into_iter().map(|game_version| async {
let semaphore = semaphore.clone();
let uploaded_files_mutex = uploaded_files_mutex.clone();
@ -130,6 +130,7 @@ pub async fn retrieve_data(
Ok::<(), Error>(())
})).await?;
lib.url = Some(format_url("maven/"));
return Ok(lib);
}

View File

@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::io::Read;
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::time::Instant;
use tokio::sync::{Mutex, Semaphore};
lazy_static! {
@ -93,7 +93,7 @@ pub async fn retrieve_data(
if !loaders.is_empty() {
version_futures.push(async {
let loaders_versions = Vec::new();
let mut loaders_versions = Vec::new();
{
let loaders_futures = loaders.into_iter().map(|(loader_version_full, version)| async {
@ -464,8 +464,9 @@ pub async fn retrieve_data(
while versions.peek().is_some() {
let now = Instant::now();
let chunk: Vec<_> = versions.by_ref().take(1).collect();
futures::future::try_join_all(chunk).await?;
let chunk: Vec<_> = versions.by_ref().take(10).collect();
let res = futures::future::try_join_all(chunk).await?;
loaders_versions.extend(res.into_iter().flatten());
chunk_index += 1;
@ -493,7 +494,7 @@ pub async fn retrieve_data(
while versions.peek().is_some() {
let now = Instant::now();
let chunk: Vec<_> = versions.by_ref().take(10).collect();
let chunk: Vec<_> = versions.by_ref().take(1).collect();
futures::future::try_join_all(chunk).await?;
chunk_index += 1;

View File

@ -44,7 +44,7 @@ async fn main() {
return;
}
let mut timer = tokio::time::interval(Duration::from_secs(30 * 60));
let mut timer = tokio::time::interval(Duration::from_secs(60 * 60));
let semaphore = Arc::new(Semaphore::new(50));
loop {
@ -189,11 +189,7 @@ pub async fn upload_file_to_bucket(
}
pub fn format_url(path: &str) -> String {
format!(
"{}/{}",
&*dotenvy::var("BASE_URL").unwrap(),
path
)
format!("{}/{}", &*dotenvy::var("BASE_URL").unwrap(), path)
}
pub async fn download_file(