Skip to content

Commit

Permalink
fix: fix missing mime in cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Aug 14, 2023
1 parent 3543b2c commit a090b15
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ docker-run:


run:
REPLEX_PORT=80 REPLEX_INCLUDE_WATCHED=0 REPLEX_REDIRECT_STREAMS=0 REPLEX_DISABLE_RELATED=1 REPLEX_DISABLE_LEAF_COUNT=0 REPLEX_DISABLE_USER_STATE=1 REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=500 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info,replex=debug" cargo watch -x run
REPLEX_PORT=80 REPLEX_INCLUDE_WATCHED=0 REPLEX_REDIRECT_STREAMS=0 REPLEX_DISABLE_RELATED=1 REPLEX_DISABLE_LEAF_COUNT=0 REPLEX_DISABLE_USER_STATE=1 REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=10 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info,replex=debug" cargo watch -x run

# run:
# REPLEX_ENABLE_CONSOLE=0 REPLEX_CACHE_TTL=0 REPLEX_HOST=https://46-4-30-217.01b0839de64b49138531cab1bf32f7c2.plex.direct:42405 RUST_LOG="info" cargo run
Expand Down
7 changes: 5 additions & 2 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl CacheIssuer for RequestIssuer {
if self.use_path {
key.push_str(req.uri().path());
}
// TODO: Clean up query. Not everything needs a cache change
// TODO: Clean up query. Not everything needs a cache change.
if self.use_query {
if let Some(query) = req.uri().query() {
key.push('?');
Expand All @@ -266,7 +266,7 @@ impl CacheIssuer for RequestIssuer {
key.push_str("|X-Plex-Language::");
key.push_str(req.header("X-Plex-Language").unwrap());
}
dbg!(&key);
// dbg!(&key);
Some(key)
}
}
Expand Down Expand Up @@ -309,12 +309,15 @@ where
if config.cache_ttl == 0 {
return None;
}
// dbg!("loading cache", &key);
self.inner.get(key)
}

async fn save_entry(&self, key: Self::Key, entry: CachedEntry) -> Result<(), Self::Error> {
let config: Config = Config::figment().extract().unwrap();
if config.cache_ttl != 0 {
//tracing::debug!(key = ?key.clone(), "Insert cache");
//dbg!("insert cache", &key);
self.inner.insert(key, entry);
}
Ok(())
Expand Down
11 changes: 9 additions & 2 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,15 @@ pub fn auto_refresh_cache() -> Cache<MemoryStore<String>, RequestIssuer> {
);
};

tracing::debug!("Refreshing cached entry");
//tracing::trace!(req = ?req, "Refreshing cached entry");
if values_list.contains_key("mime") {
req = req.header(
"Accept",
values_list.get("mime").unwrap().to_string(),
);
};

//tracing::debug!("Refreshing cached entry");
tracing::trace!(req = ?req, "Refreshing cached entry");

std::thread::spawn(move || {
match req.send() {
Expand Down

0 comments on commit a090b15

Please sign in to comment.