From 396b434b398510cd0ac354af3295c997017028ab Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Wed, 7 May 2025 20:51:54 -0700 Subject: [PATCH] quick by default --- src/generate.rs | 15 ++++++++------- src/main.rs | 9 ++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index 3907074..fd532bd 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -119,7 +119,11 @@ struct SlideContext { next_image: Option, } -pub fn generate(root_path: &PathBuf, quick: bool) -> anyhow::Result { +/// Generate an album +/// +/// `root_path` is a path to the root directory of the album. `full` if true will regenerate +/// everything, including images that already exist. +pub fn generate(root_path: &PathBuf, full: bool) -> anyhow::Result { log::debug!("Generating album in {}", root_path.display()); let config = Config::from_album(root_path.to_path_buf())?; let orig_path = env::current_dir()?; @@ -130,7 +134,7 @@ pub fn generate(root_path: &PathBuf, quick: bool) -> anyhow::Result { fs::create_dir_all(&config.output_dir)?; copy_static(&config)?; - generate_images(&config, &album, quick)?; + generate_images(&config, &album, full)?; generate_html(&config, &album)?; env::set_current_dir(orig_path)?; @@ -150,7 +154,7 @@ fn copy_static(config: &Config) -> anyhow::Result<()> { Ok(()) } -fn generate_images(config: &Config, album: &AlbumDir, quick: bool) -> anyhow::Result<()> { +fn generate_images(config: &Config, album: &AlbumDir, full: bool) -> anyhow::Result<()> { let output_path = album.path.join(&config.output_dir); // TODO: progress bar ? let mut all_images: Vec<&Image> = album.iter_all_images().collect(); @@ -159,12 +163,9 @@ fn generate_images(config: &Config, album: &AlbumDir, quick: bool) -> anyhow::Re all_images.push(&album.cover); all_images.par_iter().try_for_each(|img| { - // TODO: If orig_path is the same as the original image, and quick mode is on, skip to next - // image - // // TODO: Hard-link if it's supported, to save on hard drive space let full_size_path = output_path.join(&img.path); - if quick + if !full && full_size_path.exists() && fs::read(&full_size_path)? == fs::read(&full_size_path)? { diff --git a/src/main.rs b/src/main.rs index bd4614e..f18d518 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,8 +14,8 @@ fn main() -> anyhow::Result<()> { make_skeleton(album_path)?; println!("Album created in {}", album_path.display()); } - Commands::Generate { quick } => { - let path = generate(&album_path.to_path_buf(), quick)?; + Commands::Generate { full } => { + let path = generate(&album_path.to_path_buf(), full)?; println!("Album site generated in {}", path.display()); } } @@ -40,9 +40,8 @@ enum Commands { Init {}, /// Generates a photo album Generate { - /// Don't re-generate things that already exist (thumbnails, etc.) + /// Regenerate everything, including images that have already been generated #[arg(long)] - // TODO: Invert this to be a --full flag and default to quick? - quick: bool, + full: bool, }, }