You've already forked AstralRinth
forked from didirus/AstralRinth
Merge commit '6e3bf5fbf9558dcfcfb12f65890391945e554f7e' into feature-clean
This commit is contained in:
@@ -40,15 +40,10 @@ pub mod update;
|
||||
#[tracing::instrument]
|
||||
pub async fn remove(path: &str) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
|
||||
let mut transaction = state.pool.begin().await?;
|
||||
|
||||
Profile::remove(path, &mut transaction).await?;
|
||||
Profile::remove(path, &state.pool).await?;
|
||||
|
||||
emit_profile(path, ProfilePayloadType::Removed).await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -271,6 +271,7 @@ pub struct License {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct GalleryItem {
|
||||
pub url: String,
|
||||
pub raw_url: String,
|
||||
pub featured: bool,
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
@@ -703,6 +704,16 @@ impl CachedEntry {
|
||||
.await?;
|
||||
|
||||
for row in query {
|
||||
let row_exists = row.data.is_some();
|
||||
let parsed_data = row
|
||||
.data
|
||||
.and_then(|x| serde_json::from_value::<CacheValue>(x).ok());
|
||||
|
||||
// If data is corrupted/failed to parse ignore it
|
||||
if row_exists && parsed_data.is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if row.expires <= Utc::now().timestamp() {
|
||||
if cache_behaviour == CacheBehaviour::MustRevalidate {
|
||||
continue;
|
||||
@@ -727,10 +738,7 @@ impl CachedEntry {
|
||||
.unwrap_or(false)
|
||||
});
|
||||
|
||||
if let Some(data) = row
|
||||
.data
|
||||
.and_then(|x| serde_json::from_value::<CacheValue>(x).ok())
|
||||
{
|
||||
if let Some(data) = parsed_data {
|
||||
return_vals.push(Self {
|
||||
id: row.id,
|
||||
alias: row.alias,
|
||||
|
||||
@@ -501,13 +501,8 @@ impl Profile {
|
||||
|
||||
pub async fn remove(
|
||||
profile_path: &str,
|
||||
transaction: &mut sqlx::Transaction<'_, sqlx::Sqlite>,
|
||||
pool: &SqlitePool,
|
||||
) -> crate::Result<()> {
|
||||
if let Ok(path) = crate::api::profile::get_full_path(profile_path).await
|
||||
{
|
||||
io::remove_dir_all(&path).await?;
|
||||
}
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM profiles
|
||||
@@ -515,9 +510,14 @@ impl Profile {
|
||||
",
|
||||
profile_path
|
||||
)
|
||||
.execute(&mut **transaction)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
if let Ok(path) = crate::api::profile::get_full_path(profile_path).await
|
||||
{
|
||||
io::remove_dir_all(&path).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,21 @@ pub trait OsExt {
|
||||
|
||||
/// Gets the OS + Arch of the current system
|
||||
fn native_arch(java_arch: &str) -> Self;
|
||||
|
||||
/// Gets the OS from an OS + Arch
|
||||
fn get_os(&self) -> Self;
|
||||
}
|
||||
|
||||
impl OsExt for Os {
|
||||
fn native() -> Self {
|
||||
match std::env::consts::OS {
|
||||
"windows" => Self::Windows,
|
||||
"macos" => Self::Osx,
|
||||
"linux" => Self::Linux,
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
fn native_arch(java_arch: &str) -> Self {
|
||||
if std::env::consts::OS == "windows" {
|
||||
if java_arch == "aarch64" {
|
||||
@@ -38,12 +50,13 @@ impl OsExt for Os {
|
||||
}
|
||||
}
|
||||
|
||||
fn native() -> Self {
|
||||
match std::env::consts::OS {
|
||||
"windows" => Self::Windows,
|
||||
"macos" => Self::Osx,
|
||||
"linux" => Self::Linux,
|
||||
_ => Self::Unknown,
|
||||
fn get_os(&self) -> Self {
|
||||
match self {
|
||||
Os::OsxArm64 => Os::Osx,
|
||||
Os::LinuxArm32 => Os::Linux,
|
||||
Os::LinuxArm64 => Os::Linux,
|
||||
Os::WindowsArm64 => Os::Windows,
|
||||
_ => self.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,8 +85,8 @@ pub fn os_rule(
|
||||
if minecraft_updated
|
||||
&& (name != &Os::LinuxArm64 || name != &Os::LinuxArm32)
|
||||
{
|
||||
rule_match &=
|
||||
&Os::native() == name || &Os::native_arch(java_arch) == name;
|
||||
rule_match &= Os::native() == name.get_os()
|
||||
|| &Os::native_arch(java_arch) == name;
|
||||
} else {
|
||||
rule_match &= &Os::native_arch(java_arch) == name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user