You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathSettings {
|
|
pub(crate) database_directory: String,
|
|
pub(crate) files_directory: String,
|
|
pub(crate) thumbnail_directory: String,
|
|
}
|
|
|
|
impl Default for PathSettings {
|
|
fn default() -> Self {
|
|
Self {
|
|
database_directory: String::from("db"),
|
|
files_directory: String::from("files"),
|
|
thumbnail_directory: String::from("thumbnails"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl PathSettings {
|
|
#[inline]
|
|
pub fn database_dir(&self, root: &PathBuf) -> PathBuf {
|
|
root.join(&self.database_directory)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn files_dir(&self, root: &PathBuf) -> PathBuf {
|
|
root.join(&self.files_directory)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn thumbs_dir(&self, root: &PathBuf) -> PathBuf {
|
|
root.join(&self.thumbnail_directory)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn db_file_path(&self, root: &PathBuf) -> PathBuf {
|
|
self.database_dir(root).join("repo.db")
|
|
}
|
|
|
|
#[inline]
|
|
pub fn frontend_state_file_path(&self, root: &PathBuf) -> PathBuf {
|
|
self.database_dir(root).join("frontend-state.json")
|
|
}
|
|
}
|