Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion theseus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "theseus"
version = "0.7.0"
version = "0.7.1"
authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018"

Expand Down
5 changes: 2 additions & 3 deletions theseus/src/state/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,15 @@ 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(
&metadata_path,
&serde_json::to_vec(&metadata_fetch)?,
&state.io_semaphore,
)
.await
.unwrap();
.await?;

let mut old_metadata = state.metadata.write().await;
*old_metadata = metadata_fetch;
Expand Down
18 changes: 15 additions & 3 deletions theseus/src/state/minecraft_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
})?,
),
})
}

Expand Down
38 changes: 20 additions & 18 deletions theseus/src/state/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,26 @@ async fn read_icon_from_file(
zip_file_reader.file().entries().iter().position(|f| {
f.filename().as_str().unwrap_or_default() == icon_path
});
let mut bytes = Vec::new();
if zip_file_reader
.reader_with_entry(zip_index_option.unwrap())
.await?
.read_to_end_checked(&mut bytes)
.await
.is_ok()
{
let bytes = bytes::Bytes::from(bytes);
let path = write_cached_icon(
&icon_path,
cache_dir,
bytes,
io_semaphore,
)
.await?;

return Ok(Some(path));
if let Some(zip_index) = zip_index_option {
let mut bytes = Vec::new();
if zip_file_reader
.reader_with_entry(zip_index)
.await?
.read_to_end_checked(&mut bytes)
.await
.is_ok()
{
let bytes = bytes::Bytes::from(bytes);
let path = write_cached_icon(
&icon_path,
cache_dir,
bytes,
io_semaphore,
)
.await?;

return Ok(Some(path));
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions theseus/src/state/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion theseus_gui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "theseus_gui",
"private": true,
"version": "0.7.0",
"version": "0.7.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion theseus_gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "theseus_gui"
version = "0.7.0"
version = "0.7.1"
description = "A Tauri App"
authors = ["you"]
license = ""
Expand Down
2 changes: 1 addition & 1 deletion theseus_gui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Modrinth App",
"version": "0.7.0"
"version": "0.7.1"
},
"tauri": {
"allowlist": {
Expand Down