Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl Continuity {
pub async fn get_cached(
id: u64,
invalidate_cache: bool,
invalidate_post_cache: bool,
) -> Result<Result<Self, Vec<GlowficError>>, Box<dyn Error>> {
let board = match Board::get_cached(id, invalidate_cache).await? {
Ok(board) => board,
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -160,6 +164,7 @@ async fn main() {

let CliOptions {
use_cache,
invalidate_post_cache,
text_to_speech,
flatten_details,
jpeg,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down