mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14:21 +01:00
support multiple media cache files
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -129,7 +129,9 @@ impl Notedeck {
|
||||
|
||||
let _ = std::fs::create_dir_all(&dbpath_str);
|
||||
|
||||
let img_cache_dir = path.path(DataPathType::Cache).join(MediaCache::rel_dir());
|
||||
let img_cache_dir = path
|
||||
.path(DataPathType::Cache)
|
||||
.join(MediaCache::rel_dir(crate::imgcache::MediaCacheType::Image));
|
||||
let _ = std::fs::create_dir_all(img_cache_dir.clone());
|
||||
|
||||
let map_size = if cfg!(target_os = "windows") {
|
||||
|
||||
@@ -25,6 +25,11 @@ pub struct MediaCache {
|
||||
url_imgs: MediaCacheMap,
|
||||
}
|
||||
|
||||
pub enum MediaCacheType {
|
||||
Image,
|
||||
Gif,
|
||||
}
|
||||
|
||||
impl MediaCache {
|
||||
pub fn new(cache_dir: path::PathBuf) -> Self {
|
||||
Self {
|
||||
@@ -33,8 +38,11 @@ impl MediaCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rel_dir() -> &'static str {
|
||||
"img"
|
||||
pub fn rel_dir(cache_type: MediaCacheType) -> &'static str {
|
||||
match cache_type {
|
||||
MediaCacheType::Image => "img",
|
||||
MediaCacheType::Gif => "gif",
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -31,7 +31,7 @@ pub use context::AppContext;
|
||||
pub use error::{Error, FilterError};
|
||||
pub use filter::{FilterState, FilterStates, UnifiedSubscription};
|
||||
pub use fonts::NamedFontFamily;
|
||||
pub use imgcache::{get_texture, MediaCache, TexturedImage};
|
||||
pub use imgcache::{get_texture, MediaCache, MediaCacheType, TexturedImage};
|
||||
pub use muted::{MuteFun, Muted};
|
||||
pub use note::{NoteRef, RootIdError, RootNoteId, RootNoteIdBuf};
|
||||
pub use notecache::{CachedNote, NoteCache};
|
||||
|
||||
@@ -464,7 +464,9 @@ impl Damus {
|
||||
let decks_cache = DecksCache::default();
|
||||
|
||||
let path = DataPath::new(&data_path);
|
||||
let imgcache_dir = path.path(DataPathType::Cache).join(MediaCache::rel_dir());
|
||||
let imgcache_dir = path
|
||||
.path(DataPathType::Cache)
|
||||
.join(MediaCache::rel_dir(notedeck::MediaCacheType::Image));
|
||||
let _ = std::fs::create_dir_all(imgcache_dir.clone());
|
||||
let debug = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user