diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-28 00:30:15 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-28 00:30:15 +0300 |
commit | c251b0d5a905f19498e1d3312041b794e57fd2f8 (patch) | |
tree | 79855493ea5e834cdcc68e47d09c6d2ba6f101b7 /src/site.c | |
parent | 7bab456f05fa12420d69118e8c78f6e847b89fe7 (diff) | |
download | revela-c251b0d5a905f19498e1d3312041b794e57fd2f8.tar.gz revela-c251b0d5a905f19498e1d3312041b794e57fd2f8.zip |
Little fixes and optimizations
* Don't read image with Magick if it's up to date.
* Some memory leaks fixed. There's still are some minor leaks.
Diffstat (limited to 'src/site.c')
-rw-r--r-- | src/site.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -130,6 +130,7 @@ images_walk(struct bstnode *node, void *data) struct image *image = node->value; struct stat dstat; struct timespec ddate = { .tv_sec = image->tstamp, .tv_nsec = 0 }; + int imgupdate, thumbupdate; char htmlpath[PATH_MAX]; const char *base = rbasename(image->dst); @@ -138,18 +139,22 @@ images_walk(struct bstnode *node, void *data) if (!nmkdir(image->dst, &dstat, site->dry_run)) return false; - if (!site->dry_run) { + imgupdate = file_is_uptodate(image->dst_image, &image->modtime); + if (imgupdate == -1) goto magick_fail; + thumbupdate = file_is_uptodate(image->dst_image, &image->modtime); + if (thumbupdate == -1) goto magick_fail; + if (!site->dry_run && (!imgupdate || !thumbupdate)) { TRYWAND(site->wand, MagickReadImage(site->wand, image->source)); } - if (!optimize_image(site->wand, image->dst_image, &site->config->images, - &image->modtime, site->dry_run)) { + if (!imgupdate && !optimize_image(site->wand, image->dst_image, + &site->config->images, &image->modtime, site->dry_run)) { goto magick_fail; } - if (!optimize_image(site->wand, image->dst_thumb, &site->config->thumbnails, - &image->modtime, site->dry_run)) { + if (!thumbupdate && !optimize_image(site->wand, image->dst_thumb, + &site->config->thumbnails, &image->modtime, site->dry_run)) { goto magick_fail; } - if (!site->dry_run) { + if (!site->dry_run && (!imgupdate || !thumbupdate)) { MagickRemoveImage(site->wand); } |