Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
make download fns more arced :)
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed May 3, 2024
1 parent 7cb719b commit 54318b9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cSpell.words": [
"парсинга",
"Bukkit",
"clippy",
"cooldown",
"Datapack",
"Datapacks",
Expand Down
1 change: 0 additions & 1 deletion settings.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[core]
provider = "paper"
version = "1.20.6"
force_update = true

[plugins.simple-voice-chat]
[plugins.chunky]
Expand Down
20 changes: 12 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,25 @@ async fn download(
lock: Arc<Mutex<Lock>>,
mpb: Arc<MultiProgress>,
) -> Result<()> {
'_download_plugins: {
'_core_scope: {
let lock = Arc::clone(&lock);
let mpb = Arc::clone(&mpb);
settings.core().download(lock, mpb).await?;
}
'_plugins_scope: {
let lock = Arc::clone(&lock);
let mpb = Arc::clone(&mpb);
if let Some(plugins) = settings.plugins() {
plugins
.download_all(
&settings.core().provider().as_str(),
&settings.core().version(),
&lock,
&mpb,
settings.core().provider().as_str(),
settings.core().version(),
lock,
mpb,
)
.await?;
}
}
'_download_core: {
settings.core().download(&lock, &mpb).await?;
}
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/settings/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Core {
self.force_update = force_update;
}
/// Скачиваем `Core` и сохраняем его по стандартному пути.
pub async fn download(&self, lock: &Arc<Mutex<Lock>>, mpb: &Arc<MultiProgress>) -> Result<()> {
pub async fn download(&self, lock: Arc<Mutex<Lock>>, mpb: Arc<MultiProgress>) -> Result<()> {
let pb = mpb.add(ProgressBar::new_spinner());
pb.set_style(
ProgressStyle::with_template(
Expand Down
6 changes: 3 additions & 3 deletions src/settings/extensions/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl Plugins {
&self,
loader: &str,
game_version: &str,
lock: &Arc<Mutex<Lock>>,
mpb: &Arc<MultiProgress>,
lock: Arc<Mutex<Lock>>,
mpb: Arc<MultiProgress>,
) -> Result<()> {
let mut link_list = Vec::new();
let mut handler_list: Vec<JoinHandle<Result<()>>> = Vec::new();
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Plugins {
}
// Make handler_list
for (link, hash, build, name, pb) in link_list {
let lock = Arc::clone(lock);
let lock = Arc::clone(&lock);

handler_list.push(tokio::spawn(async move {
// get lock
Expand Down

0 comments on commit 54318b9

Please sign in to comment.