Format connected library Rust code
This commit is contained in:
@@ -372,7 +372,10 @@ async fn fetch_manifest(url: &str) -> crate::Result<ConnectedManifest> {
|
|||||||
Ok(manifest)
|
Ok(manifest)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_mrpack(url: &str, expected_sha512: &str) -> crate::Result<bytes::Bytes> {
|
async fn fetch_mrpack(
|
||||||
|
url: &str,
|
||||||
|
expected_sha512: &str,
|
||||||
|
) -> crate::Result<bytes::Bytes> {
|
||||||
let parsed = Url::parse(url)?;
|
let parsed = Url::parse(url)?;
|
||||||
if parsed.scheme() != "https" {
|
if parsed.scheme() != "https" {
|
||||||
return Err(ErrorKind::InputError(
|
return Err(ErrorKind::InputError(
|
||||||
@@ -384,11 +387,9 @@ async fn fetch_mrpack(url: &str, expected_sha512: &str) -> crate::Result<bytes::
|
|||||||
let bytes = reqwest::get(url).await?.error_for_status()?.bytes().await?;
|
let bytes = reqwest::get(url).await?.error_for_status()?.bytes().await?;
|
||||||
let hash = format!("{:x}", Sha512::digest(&bytes[..]));
|
let hash = format!("{:x}", Sha512::digest(&bytes[..]));
|
||||||
if !hash.eq_ignore_ascii_case(expected_sha512) {
|
if !hash.eq_ignore_ascii_case(expected_sha512) {
|
||||||
return Err(ErrorKind::HashError(
|
return Err(
|
||||||
expected_sha512.to_string(),
|
ErrorKind::HashError(expected_sha512.to_string(), hash).into()
|
||||||
hash,
|
);
|
||||||
)
|
|
||||||
.into());
|
|
||||||
}
|
}
|
||||||
Ok(bytes)
|
Ok(bytes)
|
||||||
}
|
}
|
||||||
@@ -478,7 +479,10 @@ async fn upsert_manifest(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_by_id(pool: &SqlitePool, id: &str) -> crate::Result<ConnectedPack> {
|
async fn get_by_id(
|
||||||
|
pool: &SqlitePool,
|
||||||
|
id: &str,
|
||||||
|
) -> crate::Result<ConnectedPack> {
|
||||||
let row = sqlx::query(
|
let row = sqlx::query(
|
||||||
"
|
"
|
||||||
SELECT id, source_url, manifest_url, name, version, version_id,
|
SELECT id, source_url, manifest_url, name, version, version_id,
|
||||||
|
|||||||
@@ -32,11 +32,10 @@ pub mod data {
|
|||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
State,
|
State, connected_library,
|
||||||
data::*,
|
data::*,
|
||||||
event::CommandPayload,
|
event::CommandPayload,
|
||||||
connected_library, jre, metadata, minecraft_auth, mr_auth, pack,
|
jre, metadata, minecraft_auth, mr_auth, pack, process,
|
||||||
process,
|
|
||||||
profile::{self, Profile, create},
|
profile::{self, Profile, create},
|
||||||
settings,
|
settings,
|
||||||
util::{
|
util::{
|
||||||
|
|||||||
Reference in New Issue
Block a user