aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/github/pull_requests.rs10
-rw-r--r--src-tauri/src/mod_management/mod.rs26
2 files changed, 29 insertions, 7 deletions
diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs
index 7e400c1a..de733feb 100644
--- a/src-tauri/src/github/pull_requests.rs
+++ b/src-tauri/src/github/pull_requests.rs
@@ -32,6 +32,7 @@ pub struct PullsApiResponseElement {
url: String,
head: CommitHead,
html_url: String,
+ labels: Vec<String>,
}
// GitHub API response JSON elements as structs
@@ -102,6 +103,14 @@ pub async fn get_pull_requests(
repo,
};
+ // Get labels and their names and put the into vector
+ let label_names: Vec<String> = item
+ .labels
+ .unwrap_or_else(Vec::new)
+ .into_iter()
+ .map(|label| label.name)
+ .collect();
+
// TODO there's probably a way to automatically serialize into the struct but I don't know yet how to
let elem = PullsApiResponseElement {
number: item.number,
@@ -112,6 +121,7 @@ pub async fn get_pull_requests(
.html_url
.ok_or(anyhow!("html_url not found"))?
.to_string(),
+ labels: label_names,
};
all_pull_requests.push(elem);
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index d5b5214e..ebbcf431 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -7,6 +7,7 @@ use thermite::prelude::ThermiteError;
use crate::NorthstarMod;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
+use std::error::Error;
use std::str::FromStr;
use std::string::ToString;
use std::{fs, path::PathBuf};
@@ -505,10 +506,14 @@ fn delete_older_versions(
/// Checks whether some mod is correctly formatted
/// Currently checks whether
/// - Some `mod.json` exists under `mods/*/mod.json`
-fn fc_sanity_check(input: &&fs::File) -> bool {
+fn fc_sanity_check(input: &&fs::File) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let mut archive = match zip::read::ZipArchive::new(*input) {
Ok(archive) => archive,
- Err(_) => return false,
+ Err(_) => {
+ return Err(Box::new(ThermiteError::UnknownError(
+ "Failed reading zip file".into(),
+ )))
+ }
};
let mut has_mods = false;
@@ -538,14 +543,22 @@ fn fc_sanity_check(input: &&fs::File) -> bool {
if name.to_str().unwrap().contains(".dll") {
log::warn!("Plugin detected, prompting user");
if !plugins::plugin_prompt() {
- return false; // Plugin detected and user denied install
+ return Err(Box::new(ThermiteError::UnknownError(
+ "Plugin detected and install denied".into(),
+ )));
}
}
}
}
}
- has_mods && mod_json_exists
+ if has_mods && mod_json_exists {
+ Ok(())
+ } else {
+ Err(Box::new(ThermiteError::UnknownError(
+ "Mod not correctly formatted".into(),
+ )))
+ }
}
// Copied from `libtermite` source code and modified
@@ -643,9 +656,8 @@ pub async fn fc_download_mod_and_install(
Err(err) => {
log::warn!("libthermite couldn't install mod {thunderstore_mod_string} due to {err:?}",);
return match err {
- ThermiteError::SanityError => Err(
- "Mod failed sanity check during install. It's probably not correctly formatted"
- .to_string(),
+ ThermiteError::SanityError(e) => Err(
+ format!("Mod failed sanity check during install. It's probably not correctly formatted. {}", e)
),
_ => Err(err.to_string()),
};