aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-02-21 21:17:52 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-02-21 21:20:16 +0100
commitd9435c988c2861dc7687aff81e6d1b7212a5bc40 (patch)
tree6e4dfdf3da7021dbf868617b789a61c7d20265b1
parent919a55c90b645b8e0df83af02bb0a0e533869b0a (diff)
downloadfiv-d9435c988c2861dc7687aff81e6d1b7212a5bc40.tar.gz
fiv-d9435c988c2861dc7687aff81e6d1b7212a5bc40.tar.xz
fiv-d9435c988c2861dc7687aff81e6d1b7212a5bc40.zip
Clean up
-rw-r--r--fiv-thumbnail.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c
index 80529d6..7bbfc92 100644
--- a/fiv-thumbnail.c
+++ b/fiv-thumbnail.c
@@ -230,8 +230,7 @@ save_thumbnail(cairo_surface_t *thumbnail, const char *path, GString *thum)
}
static cairo_surface_t *
-fiv_thumbnail_prepare(
- GFile *target, GBytes *data, gboolean *color_managed, GError **error)
+render(GFile *target, GBytes *data, gboolean *color_managed, GError **error)
{
FivIoOpenContext ctx = {
.uri = g_file_get_uri(target),
@@ -253,7 +252,7 @@ fiv_thumbnail_prepare(
}
static gboolean
-fiv_thumbnail_fallback(GFile *target, FivThumbnailSize size,
+produce_fallback(GFile *target, FivThumbnailSize size,
cairo_surface_t **surface, GError **error)
{
goffset filesize = 0;
@@ -277,8 +276,7 @@ fiv_thumbnail_fallback(GFile *target, FivThumbnailSize size,
return FALSE;
gboolean color_managed = FALSE;
- cairo_surface_t *result =
- fiv_thumbnail_prepare(target, data, &color_managed, error);
+ cairo_surface_t *result = render(target, data, &color_managed, error);
if (!result)
return FALSE;
@@ -296,10 +294,8 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size,
max_size <= FIV_THUMBNAIL_SIZE_MAX, FALSE);
const gchar *path = g_file_peek_path(target);
- if (!path || !g_file_is_native(target) /* Don't save sftp://. */) {
- return fiv_thumbnail_fallback(
- target, max_size, max_size_surface, error);
- }
+ if (!path || !g_file_is_native(target) /* Don't save sftp://. */)
+ return produce_fallback(target, max_size, max_size_surface, error);
// Make the TOCTTOU issue favour unnecessary reloading.
GStatBuf st = {};
@@ -313,14 +309,13 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size,
if (!mf) {
g_debug("%s: %s", path, e->message);
g_error_free(e);
- return fiv_thumbnail_fallback(
- target, max_size, max_size_surface, error);
+ return produce_fallback(target, max_size, max_size_surface, error);
}
gsize filesize = g_mapped_file_get_length(mf);
gboolean color_managed = FALSE;
- cairo_surface_t *surface = fiv_thumbnail_prepare(
- target, g_mapped_file_get_bytes(mf), &color_managed, error);
+ cairo_surface_t *surface =
+ render(target, g_mapped_file_get_bytes(mf), &color_managed, error);
g_mapped_file_unref(mf);
if (!surface)
return FALSE;