feat: initial commit, add fs revision storage and reporter
This commit is contained in:
40
src/storage/mod.rs
Normal file
40
src/storage/mod.rs
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user