mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-11 12:23:20 +00:00
filesystem path tool, tests pass again
This commit is contained in:
1 parent
843b9755a1
commit
e629166da3
4 files changed
+152
-43
No files matched your search
+3
-2
@@ -1,6 +1,7 @@
|
||||
pub mod anyhow_result;
|
||||
pub mod email_to_gravatar;
|
||||
pub mod filesystem;
|
||||
pub mod random_prefix_crockford_token;
|
||||
pub mod random_crockford_token;
|
||||
pub mod random_uuid;
|
||||
pub mod random_prefix_crockford_token;
|
||||
pub mod random_uuid;
|
||||
pub mod semi_persistent_cache_dir;
|
||||
@@ -0,0 +1,68 @@
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::fs;
|
||||
use crate::util::anyhow_result::AnyhowResult;
|
||||
|
||||
/// These are for files on the worker filesystems
|
||||
pub struct SemiPersistentCacheDir {
|
||||
cache_root: PathBuf,
|
||||
tts_model_root: PathBuf,
|
||||
w2l_model_root: PathBuf,
|
||||
w2l_face_templates_root: PathBuf,
|
||||
video_asset_root: PathBuf, // end bump, etc.
|
||||
}
|
||||
|
||||
impl SemiPersistentCacheDir {
|
||||
|
||||
|
||||
/// Everything is rooted at `/file_cache`.
|
||||
pub fn default_paths() -> Self {
|
||||
// NB: This is the root of the filesystem
|
||||
Self::configured_root("/file_cache/")
|
||||
}
|
||||
|
||||
pub fn configured_root(root_path: &str) -> Self {
|
||||
let cache_root = PathBuf::from(root_path);
|
||||
Self {
|
||||
cache_root: cache_root.clone(),
|
||||
tts_model_root: cache_root.join("tts/models/"),
|
||||
w2l_model_root: cache_root.join("w2l/models/"),
|
||||
w2l_face_templates_root: cache_root.join("w2l/face_templates/"),
|
||||
video_asset_root: cache_root.join("static_video_assets/"),
|
||||
}
|
||||
}
|
||||
|
||||
/// We cache TTS models here.
|
||||
pub fn tts_model_path(&self) -> &Path {
|
||||
&self.tts_model_root
|
||||
}
|
||||
|
||||
/// We cache W2L models here.
|
||||
pub fn w2l_model_path(&self) -> &Path {
|
||||
&self.w2l_model_root
|
||||
}
|
||||
|
||||
/// Face templates go here.
|
||||
pub fn w2l_face_templates_path(&self) -> &Path {
|
||||
&self.w2l_face_templates_root
|
||||
}
|
||||
|
||||
/// End bump, etc.
|
||||
pub fn video_asset_path(&self) -> &Path {
|
||||
&self.video_asset_root
|
||||
}
|
||||
|
||||
pub fn create_w2l_model_path(&self) -> AnyhowResult<()> {
|
||||
let _ = fs::create_dir_all(self.w2l_model_path())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_w2l_face_templates_path(&self) -> AnyhowResult<()> {
|
||||
let _ = fs::create_dir_all(self.w2l_face_templates_path())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_video_asset_path(&self) -> AnyhowResult<()> {
|
||||
let _ = fs::create_dir_all(self.video_asset_path())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user