From 37dd67c420b917ce7c8a8e49f6d78c51549c1abc Mon Sep 17 00:00:00 2001 From: "Ms. Haze" Date: Sat, 11 Apr 2026 13:17:13 -0400 Subject: [PATCH] Added an option to invalidate the cache of post data only --- src/cached.rs | 12 ++++++++---- src/main.rs | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/cached.rs b/src/cached.rs index 1736171..902b534 100644 --- a/src/cached.rs +++ b/src/cached.rs @@ -182,6 +182,7 @@ impl Continuity { pub async fn get_cached( id: u64, invalidate_cache: bool, + invalidate_post_cache: bool, ) -> Result>, Box> { let board = match Board::get_cached(id, invalidate_cache).await? { Ok(board) => board, @@ -192,10 +193,13 @@ impl Continuity { let mut threads = vec![]; for p in board_posts { log::info!("Downloading post {} - {}", p.id, &p.subject); - let thread = match Thread::get_cached(p.id, invalidate_cache).await? { - Ok(thread) => thread, - Err(e) => return Ok(Err(e)), - }; + let thread = + match Thread::get_cached(p.id, invalidate_cache || invalidate_post_cache) + .await? + { + Ok(thread) => thread, + Err(e) => return Ok(Err(e)), + }; threads.push(thread); } threads diff --git a/src/main.rs b/src/main.rs index aa0883c..8d5cc8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,10 @@ struct CliOptions { #[clap(long)] use_cache: bool, + /// Don't reuse data for individual posts, but still otherwise use the cache according to use_cache option. + #[clap(long)] + invalidate_post_cache: bool, + /// Simplify character and user names to improve text-to-speech output. #[clap(long)] text_to_speech: bool, @@ -160,6 +164,7 @@ async fn main() { let CliOptions { use_cache, + invalidate_post_cache, text_to_speech, flatten_details, jpeg, @@ -205,7 +210,7 @@ async fn main() { match command { Command::Post { post_id, .. } => { log::info!("Downloading post {post_id}"); - let thread = Thread::get_cached(post_id, !use_cache) + let thread = Thread::get_cached(post_id, !use_cache || invalidate_post_cache) .await .unwrap() .unwrap(); @@ -251,7 +256,7 @@ async fn main() { .. } => { log::info!("Downloading board/continuity {board_id}..."); - let continuity = Continuity::get_cached(board_id, !use_cache) + let continuity = Continuity::get_cached(board_id, !use_cache, invalidate_post_cache) .await .unwrap() .unwrap(); @@ -297,7 +302,7 @@ async fn main() { } log::info!("Downloading board/continuity {board_id}..."); - let continuity = Continuity::get_cached(board_id, !use_cache) + let continuity = Continuity::get_cached(board_id, !use_cache, invalidate_post_cache) .await .unwrap() .unwrap();