Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

refactor(cache): namespace preview poster cache by provider

Samir Hossainsd8994171ef52
diff --git a/src/cache.rs b/src/cache.rs
index d3e71eb..5b68211 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -293,10 +293,6 @@ fn get_namespaced_image_path(namespace: &str, id: &str) -> PathBuf {
path
}
-pub fn get_image_cache(id: &str) -> Option<Vec<u8>> {
- get_namespaced_image_cache(ProviderKind::MovieBox.cache_key(), id)
-}
-
pub fn get_namespaced_image_cache(namespace: &str, id: &str) -> Option<Vec<u8>> {
let path = get_namespaced_image_path(namespace, id);
if path.exists() {
@@ -315,10 +311,6 @@ pub fn get_namespaced_image_cache(namespace: &str, id: &str) -> Option<Vec<u8>>
None
}
-pub fn set_image_cache(id: &str, bytes: &[u8]) {
- set_namespaced_image_cache(ProviderKind::MovieBox.cache_key(), id, bytes);
-}
-
pub fn set_namespaced_image_cache(namespace: &str, id: &str, bytes: &[u8]) {
let path = get_namespaced_image_path(namespace, id);
let stamp = std::time::SystemTime::now()
diff --git a/src/tui/app.rs b/src/tui/app.rs
index 7ccb552..e30c187 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -3267,10 +3267,16 @@ impl App {
let tx = self.action_sender.clone();
let id2 = id.clone();
let client = self.client.http_client().clone();
+ let prov = prov;
tokio::spawn(async move {
if let Ok(Some(bytes)) = tokio::task::spawn_blocking({
let id_clone = id2.clone();
- move || crate::cache::get_image_cache(&id_clone)
+ move || {
+ crate::cache::get_namespaced_image_cache(
+ prov.cache_key(),
+ &id_clone,
+ )
+ }
})
.await
{
@@ -3283,7 +3289,11 @@ impl App {
let bytes_clone = bytes.clone();
let id_clone = id2.clone();
let _ = tokio::task::spawn_blocking(move || {
- crate::cache::set_image_cache(&id_clone, &bytes_clone)
+ crate::cache::set_namespaced_image_cache(
+ prov.cache_key(),
+ &id_clone,
+ &bytes_clone,
+ )
})
.await;
if let Some(img) = decode_poster(bytes).await {