summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-thumbnails.c
diff options
context:
space:
mode:
authorMartin Wehner <martin.wehner@gmail.com>2005-05-08 16:14:51 +0000
committerMartin Wehner <mwehner@src.gnome.org>2005-05-08 16:14:51 +0000
commit928a29d9a89ae239c379a70e8b23e464573222bc (patch)
tree92721b6a60f858ea8d2384aa522735d20909a8fe /libnautilus-private/nautilus-thumbnails.c
parentd2af91471b8d77c7e48e55b7a34703ff3c5a8fc9 (diff)
downloadnautilus-928a29d9a89ae239c379a70e8b23e464573222bc.tar.gz
Don't try to thumbnail files which have been modified in the last few
2005-05-08 Martin Wehner <martin.wehner@gmail.com> * libnautilus-private/nautilus-thumbnails.c: (thumbnail_thread_start): Don't try to thumbnail files which have been modified in the last few seconds to avoid constantly re-thumbnailing them. Current cool-off period is three seconds. Fixes bug #107418.
Diffstat (limited to 'libnautilus-private/nautilus-thumbnails.c')
-rw-r--r--libnautilus-private/nautilus-thumbnails.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index 1ef88afa8..4a6e2c5be 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -55,6 +55,9 @@
/* Should never be a reasonable actual mtime */
#define INVALID_MTIME 0
+/* Cool-off period between last file modification time and thumbnail creation */
+#define THUMBNAIL_CREATION_DELAY_SECS 3
+
static gpointer thumbnail_thread_start (gpointer data);
/* structure used for making thumbnails, associating a uri with where the thumbnail is to be stored */
@@ -493,6 +496,7 @@ thumbnail_thread_start (gpointer data)
NautilusThumbnailInfo *info = NULL;
GdkPixbuf *pixbuf;
time_t current_orig_mtime = 0;
+ time_t current_time;
/* We loop until there are no more thumbails to make, at which point
we exit the thread. */
@@ -548,6 +552,21 @@ thumbnail_thread_start (gpointer data)
#endif
pthread_mutex_unlock (&thumbnails_mutex);
+ time (&current_time);
+
+ /* Don't try to create a thumbnail if the file was modified recently.
+ This prevents constant re-thumbnailing of changing files. */
+ if (current_time < current_orig_mtime + THUMBNAIL_CREATION_DELAY_SECS &&
+ current_time >= current_orig_mtime) {
+#ifdef DEBUG_THUMBNAILS
+ g_message ("(Thumbnail Thread) Skipping: %s\n",
+ info->image_uri);
+#endif
+ /* Reschedule thumbnailing via a change notification */
+ g_timeout_add (1000, thumbnail_thread_notify_file_changed,
+ g_strdup (info->image_uri));
+ continue;
+ }
/* Create the thumbnail. */
#ifdef DEBUG_THUMBNAILS