Skip to content

Commit 92bcf09

Browse files
committed
w
1 parent aad2e08 commit 92bcf09

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/install_dependency.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use directories::ProjectDirs;
22
use flate2::read::GzDecoder;
33
use reqwest::blocking::Client;
44
use serde_json::Value;
5+
use std::collections::HashMap;
56
use std::env;
67
use std::fs::{self, File};
78
use std::io::{self};
@@ -13,8 +14,7 @@ use crate::download_file::download_file;
1314
use crate::export::prepare_templates;
1415

1516
use crate::consts::{
16-
BIN_FOLDER, GODOT4_BIN_BASE_URL, GODOT_CURRENT_VERSION, PROTOC_BASE_URL,
17-
RUST_LIB_PROJECT_FOLDER,
17+
BIN_FOLDER, GODOT_CURRENT_VERSION, GODOT_EDITOR_URL, PROTOC_BASE_URL, RUST_LIB_PROJECT_FOLDER
1818
};
1919

2020
fn create_directory_all(path: &Path) -> io::Result<()> {
@@ -161,16 +161,13 @@ pub fn download_and_extract_zip(
161161

162162
fn get_godot_url() -> Option<String> {
163163
let os = env::consts::OS;
164-
let arch = env::consts::ARCH;
165164

166-
let os_url = match (os, arch) {
167-
("linux", "x86_64") => Some("linux.x86_64.zip".to_string()),
168-
("windows", "x86_64") => Some("win64.exe.zip".to_string()),
169-
("macos", _) => Some("macos.universal.zip".to_string()),
170-
_ => None,
171-
}?;
165+
let file_map: HashMap<&str, &str> = GODOT_EDITOR_URL
166+
.iter()
167+
.cloned()
168+
.collect();
172169

173-
Some(format!("{GODOT4_BIN_BASE_URL}{os_url}"))
170+
file_map.get(os).map(|&url| url.to_string())
174171
}
175172

176173
pub fn set_executable_permission(_file_path: &Path) -> std::io::Result<()> {

0 commit comments

Comments
 (0)