- Commit
- fbb8a822f6a46161bc600f248964ffd27de273c5
- Parent
- 6751eb168376d233acf8d3a07e1744b487085b7d
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Added checks before copying files
Check that a file really needs to be copied before doing so
Custum build of stapix for tikz.pablopie.xyz
Added checks before copying files
Check that a file really needs to be copied before doing so
1 files changed, 6 insertions, 4 deletions
| Status | Name | Changes | Insertions | Deletions |
| Modified | src/main.rs | 2 files changed | 6 | 4 |
diff --git a/src/main.rs b/src/main.rs @@ -130,7 +130,9 @@ fn render_gallery( target_path.push(IMAGES_PATH); target_path.push(&pic.file_name); - copy(&pic.path, &target_path)?; + if !full_build && !needs_update(pic, &target_path) { + copy(&pic.path, &target_path)?; + } } infoln!("Copied image files to the target directory"); @@ -160,7 +162,7 @@ fn render_gallery( for (id, pic) in pics.iter().enumerate() { let thumb_path: PathBuf = ThumbPath(pic).into(); - if !full_build && !needs_rebuild(pic, &thumb_path) { + if !full_build && !needs_update(pic, &thumb_path) { thumbs_logger.job_skipped(); continue; } @@ -202,7 +204,7 @@ fn render_gallery( path.push(PAGES_PATH); path.push(pic.file_name.clone() + ".html"); - if !full_build && !needs_rebuild(&pic, &path) { + if !full_build && !needs_update(&pic, &path) { pages_logger.job_skipped(); continue; } @@ -485,7 +487,7 @@ fn render_thumbnail(pic: &GalleryEntry, thumb_path: &Path) -> Result<(), ()> { Ok(()) } -fn needs_rebuild(pic: &GalleryEntry, dst: &Path) -> bool { +fn needs_update(pic: &GalleryEntry, dst: &Path) -> bool { let dst_meta = fs::metadata(dst); if let (Ok(dst_meta), Some(pic_meta)) = (&dst_meta, &pic.metadata) { if dst_meta.modified().unwrap() > pic_meta.modified().unwrap() {