Remove unsafe unwraps causing crashes (#1135)
* Remove unsafe unwraps causing crashes * run fmt * bump version
This commit is contained in:
parent
08b26f9d5d
commit
e9e99956ad
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -5074,7 +5074,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "theseus"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"async-tungstenite",
|
||||
@ -5126,7 +5126,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "theseus_gui"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"cocoa 0.25.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "theseus"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
authors = ["Jai A <jaiagr+gpg@pm.me>"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ impl Metadata {
|
||||
.join("metadata.json.bak");
|
||||
|
||||
if metadata_path.exists() {
|
||||
std::fs::copy(&metadata_path, &metadata_backup_path).unwrap();
|
||||
std::fs::copy(&metadata_path, &metadata_backup_path)?;
|
||||
}
|
||||
|
||||
write(
|
||||
@ -154,8 +154,7 @@ impl Metadata {
|
||||
&serde_json::to_vec(&metadata_fetch)?,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.await?;
|
||||
|
||||
let mut old_metadata = state.metadata.write().await;
|
||||
*old_metadata = metadata_fetch;
|
||||
|
||||
@ -34,6 +34,8 @@ pub enum MinecraftAuthStep {
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum MinecraftAuthenticationError {
|
||||
#[error("Error reading public key during generation")]
|
||||
ReadingPublicKey,
|
||||
#[error("Failed to serialize private key to PEM: {0}")]
|
||||
PEMSerialize(#[from] p256::pkcs8::Error),
|
||||
#[error("Failed to serialize body to JSON during step {step:?}: {source}")]
|
||||
@ -63,6 +65,8 @@ pub enum MinecraftAuthenticationError {
|
||||
#[source]
|
||||
source: std::io::Error,
|
||||
},
|
||||
#[error("Error reading XBOX Session ID header")]
|
||||
NoSessionId,
|
||||
#[error("Error reading user hash")]
|
||||
NoUserHash,
|
||||
}
|
||||
@ -415,7 +419,7 @@ async fn sisu_authenticate(
|
||||
let session_id = headers
|
||||
.get("X-SessionId")
|
||||
.and_then(|x| x.to_str().ok())
|
||||
.unwrap()
|
||||
.ok_or_else(|| MinecraftAuthenticationError::NoSessionId)?
|
||||
.to_string();
|
||||
|
||||
Ok((session_id, res))
|
||||
@ -760,8 +764,16 @@ fn generate_key() -> Result<DeviceTokenKey, MinecraftAuthenticationError> {
|
||||
Ok(DeviceTokenKey {
|
||||
id,
|
||||
key: signing_key,
|
||||
x: BASE64_URL_SAFE_NO_PAD.encode(encoded_point.x().unwrap()),
|
||||
y: BASE64_URL_SAFE_NO_PAD.encode(encoded_point.y().unwrap()),
|
||||
x: BASE64_URL_SAFE_NO_PAD.encode(
|
||||
encoded_point.x().ok_or_else(|| {
|
||||
MinecraftAuthenticationError::ReadingPublicKey
|
||||
})?,
|
||||
),
|
||||
y: BASE64_URL_SAFE_NO_PAD.encode(
|
||||
encoded_point.y().ok_or_else(|| {
|
||||
MinecraftAuthenticationError::ReadingPublicKey
|
||||
})?,
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -232,9 +232,10 @@ async fn read_icon_from_file(
|
||||
zip_file_reader.file().entries().iter().position(|f| {
|
||||
f.filename().as_str().unwrap_or_default() == icon_path
|
||||
});
|
||||
if let Some(zip_index) = zip_index_option {
|
||||
let mut bytes = Vec::new();
|
||||
if zip_file_reader
|
||||
.reader_with_entry(zip_index_option.unwrap())
|
||||
.reader_with_entry(zip_index)
|
||||
.await?
|
||||
.read_to_end_checked(&mut bytes)
|
||||
.await
|
||||
@ -253,6 +254,7 @@ async fn read_icon_from_file(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@ -101,8 +101,7 @@ impl Tags {
|
||||
&serde_json::to_vec(&tags_fetch)?,
|
||||
&state.io_semaphore,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.await?;
|
||||
|
||||
let mut old_tags = state.tags.write().await;
|
||||
*old_tags = tags_fetch;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "theseus_gui",
|
||||
"private": true,
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "theseus_gui"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "Modrinth App",
|
||||
"version": "0.7.0"
|
||||
"version": "0.7.1"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user