Files
sus-manager/src/constants.rs
2025-10-26 00:28:24 +08:00

37 lines
1.2 KiB
Rust

use directories::BaseDirs;
use lazy_static::lazy_static;
use std::path::PathBuf;
use crate::models::{DLSiteManiax, RocksColumn};
const APP_DIR_NAME: &str = "sus_manager";
lazy_static! {
static ref BASE_DIRS: BaseDirs = BaseDirs::new().unwrap();
pub static ref APP_CONFIG_DIR: PathBuf =
BASE_DIRS.config_dir().to_path_buf().join(APP_DIR_NAME);
pub static ref APP_DATA_DIR: PathBuf = BASE_DIRS.data_dir().to_path_buf().join(APP_DIR_NAME);
pub static ref APP_CACHE_PATH: PathBuf = BASE_DIRS.cache_dir().to_path_buf().join(APP_DIR_NAME);
pub static ref APP_CONIFG_FILE_PATH: PathBuf = APP_CONFIG_DIR.clone().join("config.json");
pub static ref APP_DB_DATA_DIR: PathBuf = APP_DATA_DIR.clone().join("db");
pub static ref DB_OPTIONS: rocksdb::Options = get_db_options();
pub static ref DB_CF_OPTIONS: rocksdb::Options = get_cf_options();
}
lazy_static! {
pub static ref DB_COLUMNS: Vec<String> = vec![DLSiteManiax::get_column_name().to_string()];
}
fn get_db_options() -> rocksdb::Options {
let mut opts = rocksdb::Options::default();
opts.create_missing_column_families(true);
opts.create_if_missing(true);
opts
}
fn get_cf_options() -> rocksdb::Options {
let opts = rocksdb::Options::default();
opts
}