Skip to content

Commit 362db4d

Browse files
refactor: use ureq to implement multithread downloading
1 parent 626c305 commit 362db4d

File tree

11 files changed

+256
-246
lines changed

11 files changed

+256
-246
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
- name: Build Rust
2626
run: cargo build --verbose --release
2727
- name: Copy Dependencies
28-
run: cp ./resources/aria2c.exe ./target/release/aria2c.exe && cp ./resources/sciter.dll ./target/release/sciter.dll
28+
run: cp cp ./resources/sciter.dll ./target/release/sciter.dll
2929
- name: Create Windows zip
30-
run: Compress-Archive -Path ./target/release/cele-mod.exe,./target/release/aria2c.exe,./target/release/sciter.dll -DestinationPath "celemod-windows.zip"
30+
run: Compress-Archive -Path ./target/release/cele-mod.exe,./target/release/sciter.dll -DestinationPath "celemod-windows.zip"
3131
- uses: actions/upload-artifact@v4.3.1
3232
with:
3333
name: windows-exe

resources/dist.rc

-24 Bytes
Binary file not shown.

src/aria2c.rs

Lines changed: 0 additions & 231 deletions
This file was deleted.

src/celemod-ui/locales/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"单图,美术和音乐都很好": "Single pictures, art and music are very good",
210210
"MB 自己很喜欢的一张图,有 20-30 面,感觉很平和(中文名是自己翻译的)": "MB's favorite picture, with 20-30 faces, feels very peaceful (the Chinese name is my own translation)",
211211
"A 面难度在 5A - 6A,B面/C面有一些技巧,难度在 7B 的样子": "A side difficulty in 5A -6A, B -side/C side has some skills, the difficulty is 7b, it looks like 7B",
212-
"使用 aria2c 多线程下载": "Use ARIA2C multi -thread download",
212+
"使用 ureq 多线程下载": "Use ureq multi -thread download",
213213
"同步黑名单 Mod 列表": "Synchronize blacklist Mod list",
214214
"当前的 blacklist.txt 与配置文件不同。您想要同步配置文件以匹配吗?": "The current blacklist.txt is different from the configuration file. Do you want to sync the configuration files to match?",
215215
"注意,该功能不支持通配符等": "Note that this function does not support wildcard characters, etc.",

src/celemod-ui/locales/pt-BR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"单图,美术和音乐都很好": "Fotos, arte e música solteiras são muito boas",
210210
"MB 自己很喜欢的一张图,有 20-30 面,感觉很平和(中文名是自己翻译的)": "A foto favorita de MB, com 20 a 30 rostos, parece muito pacífica (o nome chinês é minha própria tradução)",
211211
"A 面难度在 5A - 6A,B面/C面有一些技巧,难度在 7B 的样子": "Uma dificuldade lateral em 5a -6a, b -aside/c lado tem algumas habilidades, a dificuldade é 7b, parece 7b",
212-
"使用 aria2c 多线程下载": "Use ARIA2C Multi -Thread Download",
212+
"使用 ureq 多线程下载": "Use ureq Multi -Thread Download",
213213
"同步黑名单 Mod 列表": "Sincronize a lista de mod da lista negra",
214214
"当前的 blacklist.txt 与配置文件不同。您想要同步配置文件以匹配吗?": "O Blacklist.txt atual é diferente do arquivo de configuração. Deseja sincronizar os arquivos de configuração para corresponder?",
215215
"注意,该功能不支持通配符等": "Observe que esta função não suporta caracteres curinga, etc.",

src/celemod-ui/locales/ru-RU.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"单图,美术和音乐都很好": "Одиночные картинки, искусство и музыка очень хорошие",
210210
"MB 自己很喜欢的一张图,有 20-30 面,感觉很平和(中文名是自己翻译的)": "Любимая фотография МБ с 20-30 лицами, чувствует себя очень мирным (китайское имя-мой собственный перевод)",
211211
"A 面难度在 5A - 6A,B面/C面有一些技巧,难度在 7B 的样子": "Боковая сложность в стороне 5a -6a, b -side/c обладает некоторыми навыками, сложность 7б, она выглядит как 7b",
212-
"使用 aria2c 多线程下载": "Используйте ARIA2C Multi -Thread Download",
212+
"使用 ureq 多线程下载": "Используйте ureq Multi -Thread Download",
213213
"同步黑名单 Mod 列表": "Синхронизировать список мод BlackList",
214214
"当前的 blacklist.txt 与配置文件不同。您想要同步配置文件以匹配吗?": "Текущий blacklist.txt отличается от файла конфигурации. Вы хотите синхронизировать файлы конфигурации?",
215215
"注意,该功能不支持通配符等": "Обратите внимание, что эта функция не поддерживает символы подстановочных знаков и т. Д.",

src/celemod-ui/locales/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
"单图,美术和音乐都很好": "单图,美术和音乐都很好",
210210
"MB 自己很喜欢的一张图,有 20-30 面,感觉很平和(中文名是自己翻译的)": "MB 自己很喜欢的一张图,有 20-30 面,感觉很平和(中文名是自己翻译的)",
211211
"A 面难度在 5A - 6A,B面/C面有一些技巧,难度在 7B 的样子": "A 面难度在 5A - 6A,B面/C面有一些技巧,难度在 7B 的样子",
212-
"使用 aria2c 多线程下载": "使用 aria2c 多线程下载",
212+
"使用 ureq 多线程下载": "使用 ureq 多线程下载",
213213
"同步黑名单 Mod 列表": "同步黑名单 Mod 列表",
214214
"当前的 blacklist.txt 与配置文件不同。您想要同步配置文件以匹配吗?": "当前的 blacklist.txt 与配置文件不同。您想要同步配置文件以匹配吗?",
215215
"注意,该功能不支持通配符等": "注意,该功能不支持通配符等",

src/celemod-ui/src/routes/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export const Home = () => {
234234
}}
235235
/>
236236

237-
{_i18n.t('使用 aria2c 多线程下载')}
237+
{_i18n.t('使用 ureq 多线程下载')}
238238
</label>
239239
</div>
240240

src/everest.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use crate::{aria2c, wegfan};
1+
use crate::{ureq, wegfan};
22

33
use anyhow::bail;
44
use lazy_static::lazy_static;
55
use serde::{Deserialize, Serialize};
6+
use ::ureq::get;
67
use std::{
78
collections::HashMap,
89
io::{BufRead, BufReader},
@@ -69,7 +70,7 @@ fn save_mod_cache(mods: &[ModInfoCached]) {
6970
}
7071

7172
pub fn get_mod_online_wegfan() -> anyhow::Result<Vec<ModInfoCached>> {
72-
let mut response: serde_json::Value = ureq::get("https://celeste.weg.fan/api/v2/mod/list")
73+
let mut response: serde_json::Value = get("https://celeste.weg.fan/api/v2/mod/list")
7374
.set(
7475
"User-Agent",
7576
&format!("CeleMod/{}-{}", env!("VERSION"), &env!("GIT_HASH")[..6]),
@@ -185,7 +186,7 @@ pub fn download_and_install_everest(
185186
let temp_path = temp_path.to_str().unwrap();
186187
let game_path = game_path.to_str().unwrap();
187188

188-
aria2c::download_file_with_progress(
189+
ureq::download_file_with_progress(
189190
url,
190191
temp_path,
191192
&mut |callback| {

src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use serde::{Deserialize, Serialize};
66

77
use anyhow::{Context, bail};
8-
use aria2c::DownloadCallbackInfo;
8+
use ureq::DownloadCallbackInfo;
99
use dirs;
1010
use everest::get_mod_cached_new;
1111
use game_scanner::prelude::Game;
@@ -40,7 +40,7 @@ use sciter::{GFX_LAYER, Value, dispatch_script_call, make_args};
4040
extern crate lazy_static;
4141
extern crate sciter;
4242

43-
mod aria2c;
43+
mod ureq;
4444
mod blacklist;
4545
mod everest;
4646
mod wegfan;
@@ -273,9 +273,9 @@ fn download_and_install_mod(
273273
url: &str,
274274
dest: &String,
275275
progress_callback: &mut dyn FnMut(DownloadCallbackInfo),
276-
use_aria2: bool,
276+
multi_thread: bool,
277277
) -> anyhow::Result<Vec<(String, String)>> {
278-
aria2c::download_file_with_progress(url, dest, progress_callback, use_aria2)?;
278+
ureq::download_file_with_progress(url, dest, progress_callback, multi_thread)?;
279279

280280
let yaml = extract_mod_for_yaml(&Path::new(&dest).to_path_buf())?;
281281

@@ -921,7 +921,7 @@ impl Handler {
921921
fn do_self_update(&self, url: String, callback: sciter::Value) {
922922
std::thread::spawn(move || {
923923
let tmp = std::env::temp_dir().join("cele-mod.exe");
924-
match aria2c::download_file_with_progress(
924+
match ureq::download_file_with_progress(
925925
&url,
926926
tmp.to_string_lossy().as_ref(),
927927
&mut |progress| {

0 commit comments

Comments
 (0)