diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -44,7 +44,9 @@ impl Modloader { | |||
44 | "forge" => Ok(Modloader::Forge), | 44 | "forge" => Ok(Modloader::Forge), |
45 | "fabric" => Ok(Modloader::Fabric), | 45 | "fabric" => Ok(Modloader::Fabric), |
46 | "quilt" => Ok(Modloader::Quilt), | 46 | "quilt" => Ok(Modloader::Quilt), |
47 | _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")), | 47 | _ => { |
48 | Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")) | ||
49 | } | ||
48 | } | 50 | } |
49 | } | 51 | } |
50 | } | 52 | } |
@@ -76,7 +78,9 @@ pub async fn check_game_versions(path: &str, force: bool) -> MLE<()> { | |||
76 | p.set_message("Update minecraft versions"); | 78 | p.set_message("Update minecraft versions"); |
77 | 79 | ||
78 | let creation_time = fs::metadata(path)?.created()?; | 80 | let creation_time = fs::metadata(path)?.created()?; |
79 | if !force && creation_time.elapsed().unwrap() < Duration::from_secs(60 * 60 * 24) { | 81 | if !force |
82 | && creation_time.elapsed().unwrap() < Duration::from_secs(60 * 60 * 24) | ||
83 | { | ||
80 | return Ok(()); | 84 | return Ok(()); |
81 | } | 85 | } |
82 | 86 | ||
@@ -107,7 +111,11 @@ impl VersionLevel { | |||
107 | } | 111 | } |
108 | } | 112 | } |
109 | 113 | ||
110 | pub async fn get(self, versions_path: &str, force_update: bool) -> MLE<String> { | 114 | pub async fn get( |
115 | self, | ||
116 | versions_path: &str, | ||
117 | force_update: bool, | ||
118 | ) -> MLE<String> { | ||
111 | let path = format!("{}/versions.json", versions_path); | 119 | let path = format!("{}/versions.json", versions_path); |
112 | check_game_versions(&path, force_update).await?; | 120 | check_game_versions(&path, force_update).await?; |
113 | let mut versions = load_game_versions(&path)?.into_iter(); | 121 | let mut versions = load_game_versions(&path)?.into_iter(); |