Try not to thumbnail FIFOs

Unless there is a writer, this may block forever.

And if there is one, we're somewhat likely to break something.
This commit is contained in:
Přemysl Eric Janouch 2023-05-21 00:12:42 +02:00
parent 00110a639a
commit 544722f8e0
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -483,6 +483,7 @@ fiv_thumbnail_produce_for_search(
static cairo_surface_t *
produce_fallback(GFile *target, FivThumbnailSize size, GError **error)
{
// Note that this comes with a TOCTTOU problem.
goffset filesize = 0;
GFileInfo *info = g_file_query_info(target,
G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_SIZE,
@ -533,6 +534,13 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
return NULL;
}
// TODO(p): Use open(O_RDONLY | O_NONBLOCK | _O_BINARY), fstat(),
// g_mapped_file_new_from_fd(), and reset the non-blocking flag on the file.
if (!S_ISREG(st.st_mode)) {
set_error(error, "not a regular file");
return NULL;
}
GError *e = NULL;
GMappedFile *mf = g_mapped_file_new(path, FALSE, &e);
if (!mf) {