gthumb r2313 - in trunk: . libgthumb



Author: mjc
Date: Mon Mar 31 19:16:44 2008
New Revision: 2313
URL: http://svn.gnome.org/viewvc/gthumb?rev=2313&view=rev

Log:
2008-03-31  Michael J. Chudobiak  <mjc svn gnome org>

        * libgthumb/file-data.c: (file_data_new), (file_data_dup),
        (file_data_update), (file_data_update_info):
        * libgthumb/file-data.h:
        Added a "can_read" permissions boolean to the FileData struct.

        * libgthumb/thumb-loader.c: (thumb_loader_start__step2):
        Do not attempt any thumbnailing on files that we can not read.
        Do not save a failed thumbnail either. This is faster and saves
        disk space. Discussed on xdg lists freedesktop org 



Modified:
   trunk/ChangeLog
   trunk/libgthumb/file-data.c
   trunk/libgthumb/file-data.h
   trunk/libgthumb/thumb-loader.c

Modified: trunk/libgthumb/file-data.c
==============================================================================
--- trunk/libgthumb/file-data.c	(original)
+++ trunk/libgthumb/file-data.c	Mon Mar 31 19:16:44 2008
@@ -79,11 +79,14 @@
 			fd->mtime = info->mtime;
 		if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE)
 			fd->mime_type = get_static_string (info->mime_type);
+		if (info->valid_fields | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS)
+			fd->can_read = info->permissions && GNOME_VFS_PERM_ACCESS_READABLE;	
 	}
 	else {
 		fd->size = (GnomeVFSFileSize) 0;
 		fd->ctime = (time_t) 0;
 		fd->mtime = (time_t) 0;
+		fd->can_read = TRUE;
 	}
 
 	/* The Exif DateTime tag is only recorded on an as-needed basis during
@@ -143,6 +146,7 @@
 	fd->size = source->size;
 	fd->ctime = source->ctime;
 	fd->mtime = source->mtime;
+	fd->can_read = source->can_read;
 	fd->exif_data_loaded = FALSE;
 	fd->exif_time = (time_t) 0;
 	fd->metadata = NULL;
@@ -195,7 +199,8 @@
 					  info,
 					  (GNOME_VFS_FILE_INFO_FOLLOW_LINKS 
 					   | GNOME_VFS_FILE_INFO_GET_MIME_TYPE 
-					   | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE));
+					   | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
+					   | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS));
 
 	if (result != GNOME_VFS_OK) {
 		fd->error = TRUE;
@@ -203,6 +208,7 @@
 		fd->mtime = 0;
 		fd->ctime = 0;
 		fd->mime_type = NULL;
+		fd->can_read = TRUE;
 		return;
 	}
 
@@ -215,6 +221,7 @@
 	fd->size = info->size;
 	fd->mtime = info->mtime;
 	fd->ctime = info->ctime;
+	fd->can_read = info->permissions && GNOME_VFS_PERM_ACCESS_READABLE;
 
 	fd_free_metadata (fd);
 
@@ -243,7 +250,8 @@
 					  info,
 					  (GNOME_VFS_FILE_INFO_FOLLOW_LINKS 
 					   | GNOME_VFS_FILE_INFO_GET_MIME_TYPE 
-					   | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE));
+					   | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE
+					   | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS));
 
 	if (result != GNOME_VFS_OK) {
 		fd->error = TRUE;
@@ -251,6 +259,7 @@
 		fd->mtime = 0;
 		fd->ctime = 0;
 		fd->mime_type = NULL;
+		fd->can_read = TRUE;
 		return;
 	}
 
@@ -262,6 +271,7 @@
 	fd->size = info->size;
 	fd->mtime = info->mtime;
 	fd->ctime = info->ctime;
+	fd->can_read = info->permissions && GNOME_VFS_PERM_ACCESS_READABLE;
 
         fd_free_metadata (fd);
 

Modified: trunk/libgthumb/file-data.h
==============================================================================
--- trunk/libgthumb/file-data.h	(original)
+++ trunk/libgthumb/file-data.h	Mon Mar 31 19:16:44 2008
@@ -40,6 +40,7 @@
 	GnomeVFSFileSize    size;
 	time_t              ctime;
 	time_t              mtime;
+	gboolean            can_read;
 	guint               exif_data_loaded : 1;
 	time_t		    exif_time;	       /* Do not access this directly. Use
 						  get_exif_time (fd) instead. This is

Modified: trunk/libgthumb/thumb-loader.c
==============================================================================
--- trunk/libgthumb/thumb-loader.c	(original)
+++ trunk/libgthumb/thumb-loader.c	Mon Mar 31 19:16:44 2008
@@ -374,7 +374,8 @@
 
 	g_return_if_fail (tl != NULL);
 	
-	if (tl->priv->file == NULL) {
+	if ((tl->priv->file == NULL) ||
+	    (tl->priv->file->can_read == FALSE)) {
 		g_signal_emit (G_OBJECT (tl),
 			       thumb_loader_signals[THUMB_ERROR],
 			       0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]