OneLauncher-Cracked/packages/oneclient_java/src/store.rs
oiupoyt 163eb0ac0c
Some checks are pending
Release Multiplatform Binaries / build (deb,appimage, linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-gnu) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-arm64, macos-14, aarch64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (dmg,app, macos-x86_64, macos-14, x86_64-apple-darwin) (push) Waiting to run
Release Multiplatform Binaries / build (nsis, windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Release Multiplatform Binaries / create-release (push) Blocked by required conditions
feat: update base to official upstream 2.3.1 with all cracked features intact (2.3.1-c1)
- Rebased onto official Polyfrost OneLauncher v2.3.1 (commit 0e49c691)
- Preserved 100% offline authentication without requiring Microsoft accounts
- Integrated custom 3D offline skin changer with UUID character slot targeting
- Maintained CustomSkinLoader auto-configuration for Ely.by and SkinRestorer
- Maintained direct GitHub Releases auto-updater pointing to oiupoyt/OneLauncher-Cracked
- Maintained mods filter popover fix eliminating text ghosting/duplication
- Configured dev profile to prevent debug symbol bloat
2026-09-07 17:38:22 +05:30

84 lines
2.5 KiB
Rust

//! A port rather than a concrete database handle so this crate does not depend
//! on the launcher's schema
use std::sync::Arc;
use crate::data::JavaRuntime;
/// Opaque so this crate never learns what is behind the port
#[derive(Debug, thiserror::Error)]
#[error("java store: {0}")]
pub struct StoreError(#[source] pub Box<dyn std::error::Error + Send + Sync>);
impl StoreError {
pub fn new(source: impl std::error::Error + Send + Sync + 'static) -> Self {
Self(Box::new(source))
}
}
pub type StoreResult<T> = Result<T, StoreError>;
#[async_trait::async_trait]
pub trait JavaStore: Send + Sync {
async fn upsert(&self, runtime: &JavaRuntime) -> StoreResult<JavaRuntime>;
async fn get_by_path(&self, absolute_path: &str) -> StoreResult<Option<JavaRuntime>>;
async fn latest_by_major(&self, major: u32) -> StoreResult<Option<JavaRuntime>>;
async fn delete_by_path(&self, absolute_path: &str) -> StoreResult<()>;
async fn list(&self) -> StoreResult<Vec<JavaRuntime>>;
}
#[derive(Debug, Default)]
pub struct MemoryJavaStore {
runtimes: std::sync::Mutex<Vec<JavaRuntime>>,
}
impl MemoryJavaStore {
#[must_use]
pub fn new() -> Arc<Self> {
Arc::new(Self::default())
}
}
#[async_trait::async_trait]
impl JavaStore for MemoryJavaStore {
async fn upsert(&self, runtime: &JavaRuntime) -> StoreResult<JavaRuntime> {
let mut runtimes = self.runtimes.lock().expect("java store poisoned");
runtimes.retain(|existing| existing.absolute_path != runtime.absolute_path);
runtimes.push(runtime.clone());
Ok(runtime.clone())
}
async fn get_by_path(&self, absolute_path: &str) -> StoreResult<Option<JavaRuntime>> {
let runtimes = self.runtimes.lock().expect("java store poisoned");
Ok(runtimes
.iter()
.find(|runtime| runtime.absolute_path == absolute_path)
.cloned())
}
async fn latest_by_major(&self, major: u32) -> StoreResult<Option<JavaRuntime>> {
let runtimes = self.runtimes.lock().expect("java store poisoned");
Ok(runtimes
.iter()
.filter(|runtime| runtime.major == major)
.max_by(|a, b| a.version.cmp(&b.version))
.cloned())
}
async fn delete_by_path(&self, absolute_path: &str) -> StoreResult<()> {
let mut runtimes = self.runtimes.lock().expect("java store poisoned");
runtimes.retain(|runtime| runtime.absolute_path != absolute_path);
Ok(())
}
async fn list(&self) -> StoreResult<Vec<JavaRuntime>> {
let runtimes = self.runtimes.lock().expect("java store poisoned");
let mut out = runtimes.clone();
out.sort_by(|a, b| b.major.cmp(&a.major).then_with(|| b.version.cmp(&a.version)));
Ok(out)
}
}