[tracker/tracker-0.6] Fixes Bug 147027, Hidden folders in PC become visible on the device after copying them



commit 02d1683929bf543a90bb73060283f7a1a4b5e2ef
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Tue Nov 24 14:36:47 2009 +0200

    Fixes Bug 147027, Hidden folders in PC become visible on the device after copying them
    
    Check for hidden flag on FAT to filter out crap-folders created by Windows.

 src/trackerd/tracker-crawler.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/trackerd/tracker-crawler.c b/src/trackerd/tracker-crawler.c
index 27f021e..6a42cca 100644
--- a/src/trackerd/tracker-crawler.c
+++ b/src/trackerd/tracker-crawler.c
@@ -22,6 +22,13 @@
 
 #include <string.h>
 
+/* VFAT check, FIXME should we move this elsewhere? */
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/msdos_fs.h>
+#include <unistd.h>
+/* End of VFAT check includes */
+
 #include <gio/gio.h>
 
 #include <libtracker-common/tracker-dbus.h>
@@ -377,6 +384,37 @@ is_path_ignored (TrackerCrawler *crawler,
 			goto done;
 		}
 
+		/* If the file is on FAT and if the hidden attribute is set, we
+		 * consider the directory to be hidden */
+
+		int fd = open (path, O_RDONLY, FALSE);
+		if (fd != -1) {
+			__u32 attrs;
+			gboolean is_hidden = FALSE;
+
+			if (ioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attrs) == 0)
+				is_hidden = attrs & ATTR_HIDDEN ? TRUE : FALSE;
+			close (fd);
+
+			if (is_hidden) {
+				for (sl = crawler->private->watch_directory_roots; sl; sl = sl->next) {
+					if (strcmp (sl->data, path) == 0) {
+					ignore = FALSE;
+					goto done;
+					}
+				}
+
+				for (sl = crawler->private->crawl_directory_roots; sl; sl = sl->next) {
+					if (strcmp (sl->data, path) == 0) {
+						ignore = FALSE;
+						goto done;
+					}
+				}
+
+				goto done;
+			}
+		}
+
 		/* Check module directory ignore patterns */
 		for (l = crawler->private->ignored_directory_patterns; l; l = l->next) {
 			if (g_pattern_match_string (l->data, basename)) {



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