diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-06-04 15:06:10 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-06-04 16:37:25 +0200 |
commit | e2adac72cc15e47b2aa47c1bea07c61a60c547d7 (patch) | |
tree | 7501ded27e719fb1bc1e857361c6d46ac65ecb3f /fiv-thumbnail.c | |
parent | 3ddb0cf20568b84e053b1608d22d55657e8ce5dd (diff) | |
download | fiv-e2adac72cc15e47b2aa47c1bea07c61a60c547d7.tar.gz fiv-e2adac72cc15e47b2aa47c1bea07c61a60c547d7.tar.xz fiv-e2adac72cc15e47b2aa47c1bea07c61a60c547d7.zip |
Use the model's mtime for validating thumbnails
Saves a syscall, generalizes fiv_thumbnail_lookup(),
wastes a tiny bit of memory per entry.
Diffstat (limited to 'fiv-thumbnail.c')
-rw-r--r-- | fiv-thumbnail.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c index d1d67c4..2dfd15f 100644 --- a/fiv-thumbnail.c +++ b/fiv-thumbnail.c @@ -579,18 +579,11 @@ fail_init: } cairo_surface_t * -fiv_thumbnail_lookup(GFile *target, FivThumbnailSize size) +fiv_thumbnail_lookup(char *uri, gint64 mtime_msec, FivThumbnailSize size) { g_return_val_if_fail(size >= FIV_THUMBNAIL_SIZE_MIN && size <= FIV_THUMBNAIL_SIZE_MAX, NULL); - // Local files only, at least for now. - GStatBuf st = {}; - const gchar *path = g_file_peek_path(target); - if (!path || g_stat(path, &st)) - return NULL; - - gchar *uri = g_file_get_uri(target); gchar *sum = g_compute_checksum_for_string(G_CHECKSUM_MD5, uri, -1); gchar *thumbnails_dir = fiv_thumbnail_get_root(); @@ -605,7 +598,7 @@ fiv_thumbnail_lookup(GFile *target, FivThumbnailSize size) const char *name = fiv_thumbnail_sizes[use].thumbnail_spec_name; gchar *wide = g_strdup_printf("%s/wide-%s/%s.webp", thumbnails_dir, name, sum); - result = read_wide_thumbnail(wide, uri, st.st_mtim.tv_sec, &error); + result = read_wide_thumbnail(wide, uri, mtime_msec / 1000, &error); if (error) { g_debug("%s: %s", wide, error->message); g_clear_error(&error); @@ -621,7 +614,7 @@ fiv_thumbnail_lookup(GFile *target, FivThumbnailSize size) gchar *path = g_strdup_printf("%s/%s/%s.png", thumbnails_dir, name, sum); - result = read_spng_thumbnail(path, uri, st.st_mtim.tv_sec, &error); + result = read_spng_thumbnail(path, uri, mtime_msec / 1000, &error); if (error) { g_debug("%s: %s", path, error->message); g_clear_error(&error); @@ -639,7 +632,6 @@ fiv_thumbnail_lookup(GFile *target, FivThumbnailSize size) g_free(thumbnails_dir); g_free(sum); - g_free(uri); return result; } |