File libfm-1.2.3-Return-back-the-workaround-on-thumbnailers.patch of Package libfm

From 08f0b7cbf2b3955e4abfdcfa66c3d91c959482dd Mon Sep 17 00:00:00 2001
From: Andriy Grytsenko <andrej@rep.kiev.ua>
Date: Sat, 9 May 2015 15:20:25 +0300
Subject: [PATCH] Return back the workaround on thumbnailers which don't save
 Thumb::MTime.

That workaround was added by commit 38edf958a9dee85a2648ca4cb05f61a2d361fa93
but later reverted in commit c7a4c8539cc5496d60dc2d6b75d1d136d5ca383c and
that still may lead to thumbnail regenerations.

This commit reintroduces that change with additional check, that way it will
rewrite thumbnail only if it misses Thumb::MTime in it.
---
 NEWS                           |  3 +++
 src/base/fm-thumbnail-loader.c | 22 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 9866ee9..822628b 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@
 
 * Improved file type detection, it failed in some cases such as DOCX.
 
+* Returned back the workaround on thumbnailers which don't save any of
+    Thumb::MTime or Thumb::URI in the thumbnail.
+
 
 Changes on 1.2.3 since 1.2.2:
 
diff --git a/src/base/fm-thumbnail-loader.c b/src/base/fm-thumbnail-loader.c
index d7037ec..01a4a75 100644
--- a/src/base/fm-thumbnail-loader.c
+++ b/src/base/fm-thumbnail-loader.c
@@ -2,7 +2,7 @@
  * fm-thumbnail-loader.c
  *
  * Copyright 2010 - 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012-2014 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
  *
  * This file is a part of the Libfm library.
  *
@@ -1149,6 +1149,18 @@ static void generate_thumbnails_with_thumbnailers(ThumbnailTask* task)
                 {
                     generated |= GENERATE_NORMAL;
                     normal_pix = backend.read_image_from_file(task->normal_path);
+                    if (normal_pix)
+                    {
+                        char *thumb_mtime = backend.get_image_text(normal_pix, "tEXt::Thumb::MTime");
+                        /* Re-save generated thumbnail to have required data
+                           in them. Some external thumbnailers not follow the
+                           specification and not set any of Thumb::URI nor
+                           Thumb::MTime, that leads to regeneration each time. */
+                        if (thumb_mtime == NULL)
+                            save_thumbnail_to_disk(task, normal_pix, task->normal_path);
+                        else
+                            g_free(thumb_mtime);
+                    }
                 }
             }
             if((task->flags & GENERATE_LARGE) && !(generated & GENERATE_LARGE))
@@ -1157,6 +1169,14 @@ static void generate_thumbnails_with_thumbnailers(ThumbnailTask* task)
                 {
                     generated |= GENERATE_LARGE;
                     large_pix = backend.read_image_from_file(task->large_path);
+                    if (large_pix)
+                    {
+                        char *thumb_mtime = backend.get_image_text(large_pix, "tEXt::Thumb::MTime");
+                        if (thumb_mtime == NULL)
+                            save_thumbnail_to_disk(task, large_pix, task->large_path);
+                        else
+                            g_free(thumb_mtime);
+                    }
                 }
             }
 
-- 
2.1.4

openSUSE Build Service is sponsored by