Skip to content

Commit

Permalink
Merge pull request #4 from modrinth/many-fixes-again
Browse files Browse the repository at this point in the history
Fix forge syncing not working
  • Loading branch information
Geometrically authored Apr 5, 2023
2 parents b9de2b4 + 0c2e913 commit fd19bb7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RUST_LOG=info,error
RUST_LOG=info

BASE_URL=https://modrinth-cdn-staging.nyc3.digitaloceanspaces.com

Expand Down
22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion daedalus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus"
version = "0.1.18"
version = "0.1.19"
authors = ["Jai A <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion daedalus/src/modded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion daedalus_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus_client"
version = "0.1.18"
version = "0.1.19"
authors = ["Jai A <[email protected]>"]
edition = "2018"

Expand Down
3 changes: 2 additions & 1 deletion daedalus_client/src/fabric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -130,6 +130,7 @@ pub async fn retrieve_data(

Ok::<(), Error>(())
})).await?;
lib.url = Some(format_url("maven/"));

return Ok(lib);
}
Expand Down
11 changes: 6 additions & 5 deletions daedalus_client/src/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions daedalus_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit fd19bb7

Please sign in to comment.