Re: [Tracker] [PATCH] tracker-files-utils.c: Handle only regular files.



Hi Juan!

I'm going to let Carlos review this. He wrote the file-utils's locking
functions during the writeback work.

Carlos is traveling at this moment, so the review will probably for
tomorrow.


Thanks


On Mon, 2009-11-30 at 13:39 +0100, Juan A. Suarez Romero wrote:
Do not handle special files like pipes or sockets. This avoids blocking when
opening such kind of files.
---
 src/libtracker-common/tracker-file-utils.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index f58537a..68b609f 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -786,6 +786,7 @@ tracker_file_unlock (GFile *file)
 gboolean
 tracker_file_is_locked (GFile *file)
 {
+     GFileInfo *file_info;
      gboolean retval = FALSE;
      gchar *path;
      gint fd;
@@ -796,6 +797,24 @@ tracker_file_is_locked (GFile *file)
              return FALSE;
      }
 
+     /* Handle regular files; skip pipes and alike */
+     file_info = g_file_query_info (file,
+                                    G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                    G_FILE_QUERY_INFO_NONE,
+                                    NULL,
+                                    NULL);
+
+     if (!file_info) {
+             return FALSE;
+     }
+
+     if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_REGULAR) {
+             g_object_unref (file_info);
+             return FALSE;
+     }
+
+     g_object_unref (file_info);
+
      path = g_file_get_path (file);
 
      if (!path) {


-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be




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