[arch-commits] Commit in tumbler/trunk (2 files)

Evangelos Foutras foutrelis at archlinux.org
Fri Nov 23 08:58:16 UTC 2018


    Date: Friday, November 23, 2018 @ 08:58:16
  Author: foutrelis
Revision: 340328

upgpkg: tumbler 0.2.3-2

Hopefully fix thumbnailing for network files (FS#60572).

Added:
  tumbler/trunk/move-sparse-file-check-to-plugins.patch
Modified:
  tumbler/trunk/PKGBUILD

-----------------------------------------+
 PKGBUILD                                |    9 
 move-sparse-file-check-to-plugins.patch |  411 ++++++++++++++++++++++++++++++
 2 files changed, 417 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2018-11-22 23:21:47 UTC (rev 340327)
+++ PKGBUILD	2018-11-23 08:58:16 UTC (rev 340328)
@@ -4,7 +4,7 @@
 
 pkgname=tumbler
 pkgver=0.2.3
-pkgrel=1
+pkgrel=2
 pkgdesc="D-Bus service for applications to request thumbnails"
 arch=('x86_64')
 url="http://www.xfce.org/"
@@ -18,11 +18,14 @@
             'libgsf: for ODF thumbnails'
             'libopenraw: for RAW thumbnails'
             'freetype2: for font thumbnails')
-source=(https://archive.xfce.org/src/xfce/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.bz2)
-sha256sums=('d022e1bd1559fba33e4bf20fb053b219eca17676ebffb1ceb214fcd58a187d40')
+source=(https://archive.xfce.org/src/xfce/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.bz2
+        move-sparse-file-check-to-plugins.patch)
+sha256sums=('d022e1bd1559fba33e4bf20fb053b219eca17676ebffb1ceb214fcd58a187d40'
+            '5a51c3f6dc393f7a0f702a52628417b70271d362db84b132ed38f030c9f49943')
 
 prepare() {
   cd "$srcdir/$pkgname-$pkgver"
+  patch -Np1 -i ../move-sparse-file-check-to-plugins.patch
 }
 
 build() {

Added: move-sparse-file-check-to-plugins.patch
===================================================================
--- move-sparse-file-check-to-plugins.patch	                        (rev 0)
+++ move-sparse-file-check-to-plugins.patch	2018-11-23 08:58:16 UTC (rev 340328)
@@ -0,0 +1,411 @@
+From da29dad8676b38b3e29396db1442d0ede6f6385d Mon Sep 17 00:00:00 2001
+From: Ali Abdallah <ali at xfce.org>
+Date: Sun, 21 Oct 2018 11:14:16 +0200
+Subject: Check for sparse video files only on plugin side.
+
+Move the sparse video files check to ffmpeg and gstreamer plugins.
+---
+ plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c | 18 ++++--
+ plugins/gst-thumbnailer/gst-thumbnailer.c       |  8 +++
+ tumbler/tumbler-util.c                          | 41 ++++++++++++-
+ tumbler/tumbler-util.h                          | 10 ++-
+ tumblerd/tumbler-registry.c                     | 82 ++++++++-----------------
+ 5 files changed, 92 insertions(+), 67 deletions(-)
+
+diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
+index 81f2922..6bc9de3 100644
+--- a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
++++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
+@@ -10,11 +10,11 @@
+  *
+  * This library is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU Library General Public License for more details.
+  *
+- * You should have received a copy of the GNU Library General 
+- * Public License along with this library; if not, write to the 
++ * You should have received a copy of the GNU Library General
++ * Public License along with this library; if not, write to the
+  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+@@ -149,7 +149,7 @@ generate_pixbuf (GdkPixbuf *source,
+     dest_height = rint (source_height / wratio);
+ 
+   /* scale the pixbuf down to the desired size */
+-  return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1), 
++  return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1),
+                                   GDK_INTERP_BILINEAR);
+ }
+ 
+@@ -180,9 +180,17 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+   g_return_if_fail (TUMBLER_IS_FILE_INFO (info));
+ 
+   /* do nothing if cancelled */
+-  if (g_cancellable_is_cancelled (cancellable)) 
++  if (g_cancellable_is_cancelled (cancellable))
+     return;
+ 
++  /* Check if is a sparse video file */
++  if (tumbler_util_guess_is_sparse (info))
++  {
++    g_debug ("Video file '%s' is probably sparse, skipping\n",
++             tumbler_file_info_get_uri (info));
++    return;
++  }
++
+   /* fetch required info */
+   thumbnail = tumbler_file_info_get_thumbnail (info);
+   g_assert (thumbnail != NULL);
+diff --git a/plugins/gst-thumbnailer/gst-thumbnailer.c b/plugins/gst-thumbnailer/gst-thumbnailer.c
+index 284a0b9..73f884b 100644
+--- a/plugins/gst-thumbnailer/gst-thumbnailer.c
++++ b/plugins/gst-thumbnailer/gst-thumbnailer.c
+@@ -570,6 +570,14 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+   if (g_cancellable_is_cancelled (cancellable))
+     return;
+ 
++  /* Check if is a sparse video file */
++  if (tumbler_util_guess_is_sparse (info))
++  {
++    g_debug ("Video file '%s' is probably sparse, skipping\n",
++             tumbler_file_info_get_uri (info));
++    return;
++  }
++
+   /* get size of dest thumb */
+   thumbnail = tumbler_file_info_get_thumbnail (info);
+   flavor = tumbler_thumbnail_get_flavor (thumbnail);
+diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c
+index 9d656d5..a414e26 100644
+--- a/tumbler/tumbler-util.c
++++ b/tumbler/tumbler-util.c
+@@ -9,11 +9,11 @@
+  *
+  * This library is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU Library General Public License for more details.
+  *
+- * You should have received a copy of the GNU Library General 
+- * Public License along with this library; if not, write to the 
++ * You should have received a copy of the GNU Library General
++ * Public License along with this library; if not, write to the
+  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+@@ -29,8 +29,12 @@
+ #include <glib.h>
+ #include <gio/gio.h>
+ 
++#include <sys/stat.h>
++
+ #include <tumbler/tumbler-util.h>
+ 
++/* Float block size used in the stat struct */
++#define TUMBLER_STAT_BLKSIZE 512.
+ 
+ 
+ gchar **
+@@ -130,3 +134,34 @@ tumbler_util_get_settings (void)
+ 
+   return settings;
+ }
++
++
++gboolean  tumbler_util_guess_is_sparse (TumblerFileInfo *info)
++{
++  gchar *filename;
++  struct stat sb;
++  gboolean ret_val = FALSE;
++
++  g_return_val_if_fail (TUMBLER_IS_FILE_INFO (info), FALSE);
++
++  filename = g_filename_from_uri (tumbler_file_info_get_uri (info), NULL, NULL);
++
++  if (G_LIKELY(filename))
++  {
++    stat (filename, &sb);
++
++    g_free (filename);
++
++    /* Test sparse files on regular ones */
++    if (S_ISREG (sb.st_mode))
++    {
++      if (((TUMBLER_STAT_BLKSIZE * sb.st_blocks) / sb.st_size) < 0.8)
++      {
++        ret_val = TRUE;
++      }
++    }
++  }
++
++  return ret_val;
++}
++
+diff --git a/tumbler/tumbler-util.h b/tumbler/tumbler-util.h
+index b68db0a..809332e 100644
+--- a/tumbler/tumbler-util.h
++++ b/tumbler/tumbler-util.h
+@@ -9,11 +9,11 @@
+  *
+  * This library is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU Library General Public License for more details.
+  *
+- * You should have received a copy of the GNU Library General 
+- * Public License along with this library; if not, write to the 
++ * You should have received a copy of the GNU Library General
++ * Public License along with this library; if not, write to the
+  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+@@ -23,12 +23,16 @@
+ 
+ #include <glib.h>
+ 
++#include <tumbler/tumbler-file-info.h>
++
+ G_BEGIN_DECLS
+ 
+ gchar **tumbler_util_get_supported_uri_schemes (void) G_GNUC_MALLOC;
+ 
+ GKeyFile *tumbler_util_get_settings (void) G_GNUC_MALLOC;
+ 
++gboolean  tumbler_util_guess_is_sparse (TumblerFileInfo *info);
++
+ G_END_DECLS
+ 
+ #endif /* !__TUMBLER_UTIL_H__ */
+diff --git a/tumblerd/tumbler-registry.c b/tumblerd/tumbler-registry.c
+index b87e2c1..317c853 100644
+--- a/tumblerd/tumbler-registry.c
++++ b/tumblerd/tumbler-registry.c
+@@ -3,18 +3,18 @@
+  * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
+  * Copyright (c) 2018      Ali Abdallah    <ali at xfce.org>
+  *
+- * This program is free software; you can redistribute it and/or 
++ * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License as
+- * published by the Free Software Foundation; either version 2 of 
++ * published by the Free Software Foundation; either version 2 of
+  * the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+- * You should have received a copy of the GNU General Public 
+- * License along with this program; if not, write to the Free 
++ * You should have received a copy of the GNU General Public
++ * License along with this program; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  * Boston, MA 02110-1301, USA.
+  */
+@@ -26,7 +26,6 @@
+ #include <glib.h>
+ #include <glib-object.h>
+ 
+-#include <sys/stat.h>
+ 
+ #include <tumbler/tumbler.h>
+ 
+@@ -34,8 +33,6 @@
+ #include <tumblerd/tumbler-specialized-thumbnailer.h>
+ #include <tumblerd/tumbler-utils.h>
+ 
+-/* Float block size used in the stat struct */
+-#define TUMBLER_STAT_BLKSIZE 512.
+ 
+ static void                tumbler_registry_finalize                  (GObject            *object);
+ static void                tumbler_registry_remove_thumbnailer        (const gchar        *key,
+@@ -83,11 +80,11 @@ tumbler_registry_class_init (TumblerRegistryClass *klass)
+   GObjectClass *gobject_class;
+ 
+   /* pre-allocate the required quarks */
+-  tumbler_registry_visited_quark = 
++  tumbler_registry_visited_quark =
+     g_quark_from_static_string ("tumbler-registry-visited-quark");
+ 
+   gobject_class = G_OBJECT_CLASS (klass);
+-  gobject_class->finalize = tumbler_registry_finalize; 
++  gobject_class->finalize = tumbler_registry_finalize;
+ }
+ 
+ 
+@@ -174,7 +171,7 @@ tumbler_registry_compare (TumblerThumbnailer *a,
+   g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (a), 0);
+   g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (b), 0);
+ 
+-  /* TODO Rewrite this based on a single get_registered() time function 
++  /* TODO Rewrite this based on a single get_registered() time function
+    * for all thumbnailer types */
+ 
+   if (!TUMBLER_IS_SPECIALIZED_THUMBNAILER (a) || !TUMBLER_IS_SPECIALIZED_THUMBNAILER (b))
+@@ -367,7 +364,7 @@ tumbler_registry_add (TumblerRegistry    *registry,
+ 
+       if (list != NULL)
+         {
+-          /* we already have thumbnailers for this combination. insert the new 
++          /* we already have thumbnailers for this combination. insert the new
+            * one at the right position in the list */
+           *list = g_list_insert_sorted (*list, g_object_ref (thumbnailer),
+                                         (GCompareFunc) tumbler_registry_compare);
+@@ -386,7 +383,7 @@ tumbler_registry_add (TumblerRegistry    *registry,
+     }
+ 
+   /* connect to the unregister signal of the thumbnailer */
+-  g_signal_connect_swapped (thumbnailer, "unregister", 
++  g_signal_connect_swapped (thumbnailer, "unregister",
+                             G_CALLBACK (tumbler_registry_remove), registry);
+ 
+   g_strfreev (hash_keys);
+@@ -409,11 +406,11 @@ tumbler_registry_remove (TumblerRegistry    *registry,
+ 
+   tumbler_mutex_lock (registry->mutex);
+ 
+-  g_signal_handlers_disconnect_matched (thumbnailer, G_SIGNAL_MATCH_DATA, 
++  g_signal_handlers_disconnect_matched (thumbnailer, G_SIGNAL_MATCH_DATA,
+                                         0, 0, NULL, NULL, registry);
+-                                        
++
+   /* remove the thumbnailer from all hash key lists */
+-  g_hash_table_foreach (registry->thumbnailers, 
++  g_hash_table_foreach (registry->thumbnailers,
+                         (GHFunc) tumbler_registry_remove_thumbnailer, thumbnailer);
+ 
+   tumbler_mutex_unlock (registry->mutex);
+@@ -465,42 +462,15 @@ tumbler_registry_get_thumbnailer_array (TumblerRegistry    *registry,
+   /* iterate over all URIs */
+   for (n = 0; n < length; ++n)
+     {
+-      gchar *filename;
+-      struct stat sb;
+-
+       g_assert (TUMBLER_IS_FILE_INFO (infos[n]));
+ 
+       /* reset */
+       file_size = 0;
+ 
+-      filename = g_filename_from_uri (tumbler_file_info_get_uri (infos[n]), NULL, NULL);
+-
+-      if (G_LIKELY(filename))
+-      {
+-        stat (filename, &sb);
+-
+-        g_free (filename);
+-
+-        /* Test sparse files on regular ones */
+-        if (S_ISREG (sb.st_mode))
+-        {
+-          if (((TUMBLER_STAT_BLKSIZE * sb.st_blocks) / sb.st_size) < 0.8)
+-          {
+-            g_debug ("'%s' is probably a sparse file, skipping\n", tumbler_file_info_get_uri (infos[n]));
+-            continue;
+-          }
+-        }
+-      }
+-      else
+-      {
+-        g_warning ("Failed to get filename from uri for '%s', skipping\n", tumbler_file_info_get_uri (infos[n]));
+-        continue;
+-      }
+-
+       /* determine the URI scheme and generate a hash key */
+       gfile = g_file_new_for_uri (tumbler_file_info_get_uri (infos[n]));
+       scheme = g_file_get_uri_scheme (gfile);
+-      hash_key = g_strdup_printf ("%s-%s", scheme, 
++      hash_key = g_strdup_printf ("%s-%s", scheme,
+                                   tumbler_file_info_get_mime_type (infos[n]));
+ 
+       /* get list of thumbnailer that can handle this URI/MIME type pair */
+@@ -593,8 +563,8 @@ tumbler_registry_update_supported (TumblerRegistry *registry)
+     g_object_set_qdata (lp->data, tumbler_registry_visited_quark, NULL);
+ 
+   /* create a hash table to collect unique URI scheme / MIME type pairs */
+-  unique_pairs = g_hash_table_new_full (g_str_hash, g_str_equal, 
+-                                        (GDestroyNotify) g_free, 
++  unique_pairs = g_hash_table_new_full (g_str_hash, g_str_equal,
++                                        (GDestroyNotify) g_free,
+                                         (GDestroyNotify) free_pair);
+ 
+   /* prepare array */
+@@ -611,8 +581,8 @@ tumbler_registry_update_supported (TumblerRegistry *registry)
+       uri_schemes = tumbler_thumbnailer_get_uri_schemes (lp->data);
+ 
+       /* insert all MIME types & URI schemes into the hash table */
+-      for (n = 0; 
+-           mime_types != NULL && uri_schemes != NULL && mime_types[n] != NULL; 
++      for (n = 0;
++           mime_types != NULL && uri_schemes != NULL && mime_types[n] != NULL;
+            ++n)
+         {
+           /* remember the MIME type so that we can later reuse it without copying */
+@@ -620,8 +590,8 @@ tumbler_registry_update_supported (TumblerRegistry *registry)
+ 
+           for (u = 0; uri_schemes[u] != NULL; ++u)
+             {
+-              /* remember the URI scheme for this pair so that we can later reuse it 
+-               * without copying. Only remember it once (n==0) to avoid segmentation 
++              /* remember the URI scheme for this pair so that we can later reuse it
++               * without copying. Only remember it once (n==0) to avoid segmentation
+                * faults when freeing the list */
+               if (n == 0)
+                 g_ptr_array_add (used_strings, uri_schemes[u]);
+@@ -646,9 +616,9 @@ tumbler_registry_update_supported (TumblerRegistry *registry)
+       g_free (mime_types);
+       g_free (uri_schemes);
+ 
+-      /* mark the thumbnailer as visited so we don't generate its 
++      /* mark the thumbnailer as visited so we don't generate its
+        * MIME type & URI scheme pairs multiple times */
+-      g_object_set_qdata (lp->data, tumbler_registry_visited_quark, 
++      g_object_set_qdata (lp->data, tumbler_registry_visited_quark,
+                           GUINT_TO_POINTER (1));
+     }
+ 
+@@ -667,7 +637,7 @@ tumbler_registry_update_supported (TumblerRegistry *registry)
+   /* insert all unique URI scheme / MIME type pairs into string arrays */
+   n = 0;
+   g_hash_table_iter_init (&iter, unique_pairs);
+-  while (g_hash_table_iter_next (&iter, NULL, (gpointer) &pair)) 
++  while (g_hash_table_iter_next (&iter, NULL, (gpointer) &pair))
+     {
+       /* fill the cache arrays with copied values */
+       registry->uri_schemes[n] = g_strdup (pair[0]);
+@@ -700,7 +670,7 @@ tumbler_registry_get_supported (TumblerRegistry     *registry,
+   g_return_if_fail (TUMBLER_IS_REGISTRY (registry));
+ 
+   tumbler_mutex_lock (registry->mutex);
+-  
++
+   if (uri_schemes != NULL)
+     *uri_schemes = (const gchar *const *)registry->uri_schemes;
+ 
+@@ -740,14 +710,14 @@ tumbler_registry_set_preferred (TumblerRegistry    *registry,
+   g_return_if_fail (thumbnailer == NULL || TUMBLER_IS_THUMBNAILER (thumbnailer));
+ 
+   tumbler_mutex_lock (registry->mutex);
+-  
++
+   if (thumbnailer == NULL)
+     {
+       g_hash_table_remove (registry->preferred_thumbnailers, hash_key);
+     }
+   else
+     {
+-      g_hash_table_insert (registry->preferred_thumbnailers, 
++      g_hash_table_insert (registry->preferred_thumbnailers,
+                            g_strdup (hash_key), g_object_ref (thumbnailer));
+     }
+ 
+-- 
+cgit v1.2.1
+



More information about the arch-commits mailing list