From 109ed6d6b6c9618beae122f4aea318d6fda14c87 Mon Sep 17 00:00:00 2001 From: lostb1t Date: Wed, 10 Jul 2024 09:07:23 +0000 Subject: [PATCH] fix: deprecate auto refresh cache --- Makefile | 5 +++-- src/config.rs | 14 +------------- src/routes.rs | 5 +++-- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 0869a49..603b65d 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ run: REPLEX_VIDEO_TRANSCODE_FALLBACK_FOR="4k" \ REPLEX_AUTO_SELECT_VERSION=0 \ REPLEX_FORCE_MAXIMUM_QUALITY=1 \ - REPLEX_CACHE_ROWS=0 \ + REPLEX_CACHE_ROWS=1 \ + REPLEX_CACHE_ROWS_REFRESH=0 \ REPLEX_HERO_ROWS="home.movies.recent,movies.recent,movie.recentlyadded,movie.topunwatched,movie.recentlyviewed,hub.movie.recentlyreleased,home.television.recent,tv.inprogress,tv.recentlyaired" \ REPLEX_PORT=8000 \ REPLEX_INCLUDE_WATCHED=0 \ @@ -31,7 +32,7 @@ run: REPLEX_DISABLE_LEAF_COUNT=0 \ REPLEX_DISABLE_USER_STATE=0 \ REPLEX_ENABLE_CONSOLE=0 \ - REPLEX_CACHE_TTL=0 \ + REPLEX_CACHE_TTL=600 \ REPLEX_NTF_WATCHLIST_FORCE=1 \ RUST_LOG="info,replex=info" \ RUSTFLAGS=-Awarnings \ diff --git a/src/config.rs b/src/config.rs index c2ddddb..245214f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,6 +24,7 @@ pub struct Config { deserialize_with = "figment::util::bool_from_str_or_int" )] pub cache_rows: bool, + #[deprecated] #[serde( default = "default_as_true", deserialize_with = "figment::util::bool_from_str_or_int" @@ -133,28 +134,15 @@ impl Config { } pub fn dynamic(req: &salvo::Request) -> Figment { - // dbg!(&req); - // use base64::{Engine as _, alphabet, engine::{self, general_purpose}}; - // use base32::{decode, CrockfordBase32}; - // use crockford::decode; let host = req.headers().get("HOST").unwrap().to_str().unwrap(); let mut config = Config::figment(); if host.contains("replex.stream") { use data_encoding::BASE32; let val: Vec<&str> = host.split(".replex.stream").collect(); let owned_val = val[0].to_ascii_uppercase().to_owned(); - // dbg!(&val); - // let mut decoded_host: String = String::new(); - // let decoded_host = general_purpose::STANDARD - // .decode(val[0]).unwrap(); - // let decoded_host = decode(CrockfordBase32, &owned_val[..]); - // let decoded_host: String = crockford::decode(val[0].to_uppercase()).unwrap().to_string(); let mut output = vec![0; BASE32.decode_len(owned_val.len()).unwrap()]; let len = BASE32.decode_mut(owned_val.as_bytes(), &mut output).unwrap(); - // dbg!(std::str::from_utf8(&output[0 .. len]).unwrap()); config = config.join(("host", std::str::from_utf8(&output[0 .. len]).unwrap())); - // config = config.join(("host", decoded_host)); - } config // Figment::new().merge(Env::prefixed("REPLEX_")) diff --git a/src/routes.rs b/src/routes.rs index 701ed76..24a8c95 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -36,6 +36,7 @@ pub fn route() -> Router { // .unwrap(), // ); + //let default_cache = default_cache() let mut router = Router::with_hoop(Cors::permissive().into_handler()) .hoop(Logger::new()) .hoop(should_skip) @@ -148,13 +149,13 @@ pub fn route() -> Router { .push( Router::new() .path(PLEX_HUBS_PROMOTED) - .hoop(auto_refresh_cache()) + .hoop(default_cache()) .get(transform_hubs_home), ) .push( Router::new() .path(format!("{}/", PLEX_HUBS_SECTIONS)) - .hoop(auto_refresh_cache()) + .hoop(default_cache()) .get(get_hubs_sections), ) .push(