feat: initial commit, add fs revision storage and reporter

This commit is contained in:
2026-02-02 00:22:51 -08:00
commit c48880d0ca
9 changed files with 1228 additions and 0 deletions

40
src/storage/mod.rs Normal file
View File

@@ -0,0 +1,40 @@
pub mod fs;
use std::path::PathBuf;
use crate::{Data, error::Result};
pub trait StorageImpl {
fn get_revision(&self) -> Result<usize>;
fn store_revision(&self, app_state: Data) -> Result<()>;
}
pub enum Storage {
FS(fs::FSStorage),
}
pub const IGNORE_FILES: [&str; 6] = ["assets", "cache", "catpacks", "logs", "meta", "metacache"];
impl StorageImpl for Storage {
fn get_revision(&self) -> Result<usize> {
match self {
Self::FS(storage) => storage.get_revision(),
}
}
fn store_revision(&self, app_state: Data) -> Result<()> {
match self {
Self::FS(storage) => storage.store_revision(app_state),
}
}
}
pub fn get_storage_from_env() -> Storage {
Storage::FS(fs::FSStorage)
}
pub fn base_path_prism() -> PathBuf {
dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join("PrismLauncher")
}