changeset 1927:d1a5b8633919

always check for sidecars by readdir
author Vladimir Nadvornik <nadvornik@suse.cz>
date Fri, 30 Sep 2011 23:02:26 +0200
parents 776d6784c7c3
children 51d96f795ecc
files src/bar_sort.c src/cache_maint.c src/collect-io.c src/filedata.c src/filedata.h src/layout.c src/layout_image.c src/layout_util.c src/main.c src/pan-calendar.c src/pan-timeline.c src/pan-view.c src/remote.c src/search.c src/thumb.c src/thumb_standard.c src/trash.c src/view_dir.c src/view_dir_list.c src/view_dir_tree.c
diffstat 20 files changed, 155 insertions(+), 153 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_sort.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/bar_sort.c	Fri Sep 30 23:02:26 2011 +0200
@@ -99,7 +99,7 @@
 	history_list_free_key(SORT_KEY_COLLECTIONS);
 	bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
 
-	dir_fd = file_data_new_simple(get_collections_dir());
+	dir_fd = file_data_new_dir(get_collections_dir());
 	filelist_read(dir_fd, &list, NULL);
 	file_data_unref(dir_fd);
 
--- a/src/cache_maint.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/cache_maint.c	Fri Sep 30 23:02:26 2011 +0200
@@ -291,7 +291,7 @@
 		cache_folder = get_thumbnails_cache_dir();
 		}
 
-	dir_fd = file_data_new_simple(cache_folder);
+	dir_fd = file_data_new_dir(cache_folder);
 	if (!filelist_read(dir_fd, NULL, &dlist))
 		{
 		file_data_unref(dir_fd);
@@ -370,7 +370,7 @@
 
 	base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
 	base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
-	dir_fd = file_data_new_simple(base);
+	dir_fd = file_data_new_dir(base);
 	g_free(base);
 
 	if (filelist_read(dir_fd, &flist, &dlist))
@@ -442,7 +442,7 @@
 	GList *work;
 
 	cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
-	cachedir_fd = file_data_new_simple(cachedir);
+	cachedir_fd = file_data_new_dir(cachedir);
 	g_free(cachedir);
 
 	filelist_read(cachedir_fd, &list, NULL);
@@ -856,7 +856,7 @@
 
 		spinner_set_interval(cd->spinner, SPINNER_SPEED);
 
-		dir_fd = file_data_new_simple(path);
+		dir_fd = file_data_new_dir(path);
 		cache_manager_render_folder(cd, dir_fd);
 		file_data_unref(dir_fd);
 		while (cache_manager_render_file(cd));
@@ -1062,21 +1062,21 @@
 	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
 
 	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL);
-	dir_fd = file_data_new_simple(path);
+	dir_fd = file_data_new_dir(path);
 	filelist_read(dir_fd, &list, NULL);
 	cd->list = list;
 	file_data_unref(dir_fd);
 	g_free(path);
 
 	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL);
-	dir_fd = file_data_new_simple(path);
+	dir_fd = file_data_new_dir(path);
 	filelist_read(dir_fd, &list, NULL);
 	cd->list = g_list_concat(cd->list, list);
 	file_data_unref(dir_fd);
 	g_free(path);
 
 	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL);
-	dir_fd = file_data_new_simple(path);
+	dir_fd = file_data_new_dir(path);
 	filelist_read(dir_fd, &list, NULL);
 	cd->list = g_list_concat(cd->list, list);
 	file_data_unref(dir_fd);
--- a/src/collect-io.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/collect-io.c	Fri Sep 30 23:02:26 2011 +0200
@@ -673,7 +673,7 @@
 	GList *work;
 	FileData *dir_fd;
 
-	dir_fd = file_data_new_simple(get_collections_dir());
+	dir_fd = file_data_new_dir(get_collections_dir());
 	filelist_read(dir_fd, &list, NULL);
 	file_data_unref(dir_fd);
 
--- a/src/filedata.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/filedata.c	Fri Sep 30 23:02:26 2011 +0200
@@ -383,11 +383,13 @@
 	return ret;
 }
 
-static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean check_sidecars, GHashTable *basename_hash)
+static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean disable_sidecars, GHashTable *basename_hash)
 {
 	FileData *fd;
 
-	DEBUG_2("file_data_new: '%s' %d %d", path_utf8, check_sidecars, !!basename_hash);
+	DEBUG_2("file_data_new: '%s' %d %d", path_utf8, disable_sidecars, !!basename_hash);
+
+	if (S_ISDIR(st->st_mode)) disable_sidecars = TRUE; 
 
 	if (!file_data_pool)
 		file_data_pool = g_hash_table_new(g_str_hash, g_str_equal);
@@ -412,10 +414,13 @@
 	if (fd)
 		{
 		gboolean changed;
+		
+		if (disable_sidecars) file_data_disable_grouping(fd, TRUE);
+		
 		if (basename_hash) 
 			{
 			file_data_basename_hash_insert(basename_hash, fd);
-			if (check_sidecars)
+			if (!disable_sidecars)
 				file_data_check_sidecars(fd, basename_hash);
 			}
 		
@@ -423,7 +428,7 @@
 			changed = file_data_check_changed_files(fd);
 		else
 			changed = file_data_check_changed_files_recursive(fd, st);
-		if (changed && check_sidecars && sidecar_file_priority(fd->extension))
+		if (changed && !disable_sidecars && sidecar_file_priority(fd->extension))
 			file_data_check_sidecars(fd, basename_hash);
 		DEBUG_2("file_data_pool hit: '%s' %s", fd->path, changed ? "(changed)" : "");
 		
@@ -437,65 +442,21 @@
 	fd->mode = st->st_mode;
 	fd->ref = 1;
 	fd->magick = 0x12345678;
+	
+	if (disable_sidecars) fd->disable_grouping = TRUE;
 
 	file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */
 	if (basename_hash) file_data_basename_hash_insert(basename_hash, fd);
 
-	if (check_sidecars)
+	if (!disable_sidecars)
+		{
+		g_assert(basename_hash);
 		file_data_check_sidecars(fd, basename_hash);
+		}
 
 	return fd;
 }
 
-/* extension must contain only ASCII characters */
-static GList *check_case_insensitive_ext(gchar *path)
-{
-	gchar *sl;
-	gchar *extl;
-	gint ext_len;
-	GList *list = NULL;
-
-	sl = path_from_utf8(path);
-
-	extl = strrchr(sl, '.');
-	if (extl)
-		{
-		gint i, j;
-		extl++; /* the first char after . */
-		ext_len = strlen(extl);
-	
-		for (i = 0; i < (1 << ext_len); i++)
-			{
-			struct stat st;
-			gboolean skip = FALSE;
-			for (j = 0; j < ext_len; j++)
-				{
-				if (i & (1 << (ext_len - 1 - j))) 
-					{
-					extl[j] = g_ascii_tolower(extl[j]);
-					/* make sure the result does not contain duplicates */
-					if (extl[j] == g_ascii_toupper(extl[j]))
-						{
-						/* no change, probably a number, we have already tested this combination */
-						skip = TRUE;
-						break;
-						}
-					}
-				else
-					extl[j] = g_ascii_toupper(extl[j]);
-				}
-			if (skip) continue;
-
-			if (stat(sl, &st) == 0)
-				{
-				list = g_list_prepend(list, file_data_new_local(sl, &st, FALSE, FALSE));
-				}
-			}
-		}
-	g_free(sl);
-
-	return list;
-}
 
 static void file_data_check_sidecars(FileData *fd, GHashTable *basename_hash)
 {
@@ -511,10 +472,7 @@
 	base_len = fd->extension - fd->path;
 	fname = g_string_new_len(fd->path, base_len);
 
-	if (basename_hash)
-		{
-		basename_list = g_hash_table_lookup(basename_hash, fname->str);
-		}
+	basename_list = g_hash_table_lookup(basename_hash, fname->str);
 
 
 	/* check for possible sidecar files;
@@ -533,28 +491,17 @@
 		gchar *ext = work->data;
 		work = work->next;
 
-		if (!basename_hash)
-			{
-			GList *new_list;
-			g_string_truncate(fname, base_len);
-			g_string_append(fname, ext);
-			new_list = check_case_insensitive_ext(fname->str);
-			group_list = g_list_concat(group_list, new_list);
-			}
-		else
+		const GList *work2 = basename_list;
+			
+		while (work2)
 			{
-			const GList *work2 = basename_list;
+			FileData *sfd = work2->data;
 			
-			while (work2)
+			if (g_ascii_strcasecmp(ext, sfd->extension) == 0) 
 				{
-				FileData *sfd = work2->data;
-				
-				if (g_ascii_strcasecmp(ext, sfd->extension) == 0) 
-					{
-					group_list = g_list_append(group_list, file_data_ref(sfd));
-					}
-				work2 = work2->next;
+				group_list = g_list_append(group_list, file_data_ref(sfd));
 				}
+			work2 = work2->next;
 			}
 		}
 	g_string_free(fname, TRUE);
@@ -583,28 +530,15 @@
 }
 
 
-static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean check_sidecars, GHashTable *basename_hash)
+static FileData *file_data_new_local(const gchar *path, struct stat *st, gboolean disable_sidecars, GHashTable *basename_hash)
 {
 	gchar *path_utf8 = path_to_utf8(path);
-	FileData *ret = file_data_new(path_utf8, st, check_sidecars, basename_hash);
+	FileData *ret = file_data_new(path_utf8, st, disable_sidecars, basename_hash);
 
 	g_free(path_utf8);
 	return ret;
 }
 
-FileData *file_data_new_simple(const gchar *path_utf8)
-{
-	struct stat st;
-
-	if (!stat_utf8(path_utf8, &st))
-		{
-		st.st_size = 0;
-		st.st_mtime = 0;
-		}
-
-	return file_data_new(path_utf8, &st, TRUE, NULL);
-}
-
 FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd)
 {
 	sfd->parent = target;
@@ -1018,7 +952,7 @@
 	return TRUE;
 }
 
-static gboolean filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gboolean follow_symlinks)
+static gboolean filelist_read_real(const gchar *dir_path, GList **files, GList **dirs, gboolean follow_symlinks)
 {
 	DIR *dp;
 	struct dirent *dir;
@@ -1033,7 +967,7 @@
 	if (files) *files = NULL;
 	if (dirs) *dirs = NULL;
 
-	pathl = path_from_utf8(dir_fd->path);
+	pathl = path_from_utf8(dir_path);
 	if (!pathl) return FALSE;
 
 	dp = opendir(pathl);
@@ -1071,14 +1005,14 @@
 				    strcmp(name, GQ_CACHE_LOCAL_METADATA) != 0 &&
 				    strcmp(name, THUMB_FOLDER_LOCAL) != 0)
 					{
-					dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, FALSE, NULL));
+					dlist = g_list_prepend(dlist, file_data_new_local(filepath, &ent_sbuf, TRUE, NULL));
 					}
 				}
 			else
 				{
 				if (files && filter_name_exists(name))
 					{
-					flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, TRUE, basename_hash));
+					flist = g_list_prepend(flist, file_data_new_local(filepath, &ent_sbuf, FALSE, basename_hash));
 					}
 				}
 			}
@@ -1105,12 +1039,68 @@
 
 gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs)
 {
-	return filelist_read_real(dir_fd, files, dirs, TRUE);
+	return filelist_read_real(dir_fd->path, files, dirs, TRUE);
 }
 
 gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs)
 {
-	return filelist_read_real(dir_fd, files, dirs, FALSE);
+	return filelist_read_real(dir_fd->path, files, dirs, FALSE);
+}
+
+FileData *file_data_new_simple(const gchar *path_utf8)
+{
+	gchar *dir;
+	struct stat st;
+	FileData *fd;
+	GList *files;
+
+	if (!stat_utf8(path_utf8, &st))
+		{
+		st.st_size = 0;
+		st.st_mtime = 0;
+		}
+
+	if (S_ISDIR(st.st_mode))
+		return file_data_new(path_utf8, &st, TRUE, NULL);
+	
+	dir = remove_level_from_path(path_utf8);
+	
+	filelist_read_real(dir, &files, NULL, TRUE);
+	
+	fd = g_hash_table_lookup(file_data_pool, path_utf8);
+	g_assert(fd);
+	file_data_ref(fd);
+	
+	filelist_free(files);
+	g_free(dir);
+	return fd;
+}
+
+FileData *file_data_new_no_grouping(const gchar *path_utf8)
+{
+	struct stat st;
+
+	if (!stat_utf8(path_utf8, &st))
+		{
+		st.st_size = 0;
+		st.st_mtime = 0;
+		}
+
+	return file_data_new(path_utf8, &st, TRUE, NULL);
+}
+
+FileData *file_data_new_dir(const gchar *path_utf8)
+{
+	struct stat st;
+
+	if (!stat_utf8(path_utf8, &st))
+		{
+		st.st_size = 0;
+		st.st_mtime = 0;
+		}
+
+	g_assert(S_ISDIR(st.st_mode));
+	return file_data_new(path_utf8, &st, TRUE, NULL);
 }
 
 void filelist_free(GList *list)
--- a/src/filedata.h	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/filedata.h	Fri Sep 30 23:02:26 2011 +0200
@@ -22,9 +22,15 @@
 gchar *text_from_size_abrev(gint64 size);
 const gchar *text_from_time(time_t t);
 
-/* this expects a utf-8 path */
+/* scan for sidecar files - expensive */
 FileData *file_data_new_simple(const gchar *path_utf8);
 
+/* should be used on helper files which can't have sidecars */
+FileData *file_data_new_no_grouping(const gchar *path_utf8);
+
+/* should be used on dirs */
+FileData *file_data_new_dir(const gchar *path_utf8);
+
 #ifdef DEBUG_FILEDATA
 FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
 void file_data_unref_debug(const gchar *file, gint line, FileData *fd);
--- a/src/layout.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/layout.c	Fri Sep 30 23:02:26 2011 +0200
@@ -898,7 +898,7 @@
 				file_data_unregister_real_time_monitor(lw->dir_fd);
 				file_data_unref(lw->dir_fd);
 				}
-			lw->dir_fd = file_data_new_simple(base);
+			lw->dir_fd = file_data_new_dir(base);
 			file_data_register_real_time_monitor(lw->dir_fd);
 			g_free(base);
 			}
--- a/src/layout_image.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/layout_image.c	Fri Sep 30 23:02:26 2011 +0200
@@ -634,7 +634,7 @@
 				FileData *dir_fd;
 
 				base = remove_level_from_path(fd->path);
-				dir_fd = file_data_new_simple(base);
+				dir_fd = file_data_new_dir(base);
 				if (dir_fd != lw->dir_fd)
 					{
 					layout_set_fd(lw, dir_fd);
--- a/src/layout_util.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/layout_util.c	Fri Sep 30 23:02:26 2011 +0200
@@ -1064,7 +1064,7 @@
 	if (!path) return;
 	
 	/* Open previous path */
-	dir_fd = file_data_new_simple(path);
+	dir_fd = file_data_new_dir(path);
 	layout_set_fd(lw, dir_fd);
 	file_data_unref(dir_fd);
 }
@@ -1081,7 +1081,7 @@
 
 	if (path)
 		{
-		FileData *dir_fd = file_data_new_simple(path);
+		FileData *dir_fd = file_data_new_dir(path);
 		layout_set_fd(lw, dir_fd);
 		file_data_unref(dir_fd);
 		}
--- a/src/main.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/main.c	Fri Sep 30 23:02:26 2011 +0200
@@ -141,7 +141,7 @@
 
 	path_parsed = g_strdup(dir);
 	parse_out_relatives(path_parsed);
-	dir_fd = file_data_new_simple(path_parsed);
+	dir_fd = file_data_new_dir(path_parsed);
 	
 
 	if (filelist_read(dir_fd, &files, NULL))
--- a/src/pan-calendar.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/pan-calendar.c	Fri Sep 30 23:02:26 2011 +0200
@@ -333,7 +333,7 @@
 			 */
 
 			g_snprintf(fake_path, sizeof(fake_path), "//%04d-%02d-%02d", year, month, day);
-			fd = file_data_new_simple(fake_path);
+			fd = file_data_new_no_grouping(fake_path);
 			fd->date = dt;
 			pi_day = pan_item_box_new(pw, fd, x, y, PAN_CAL_DAY_WIDTH, PAN_CAL_DAY_HEIGHT,
 						  PAN_CAL_DAY_BORDER,
--- a/src/pan-timeline.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/pan-timeline.c	Fri Sep 30 23:02:26 2011 +0200
@@ -133,7 +133,7 @@
 
 			y += pi->height;
 
-			pi_day = pan_item_box_new(pw, file_data_new_simple(fd->path), x, y, 0, 0,
+			pi_day = pan_item_box_new(pw, file_data_ref(fd), x, y, 0, 0,
 						  PAN_BOX_OUTLINE_THICKNESS,
 						  PAN_BOX_COLOR, PAN_BOX_ALPHA,
 						  PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
--- a/src/pan-view.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/pan-view.c	Fri Sep 30 23:02:26 2011 +0200
@@ -2297,7 +2297,7 @@
 		}
 	else
 		{
-		FileData *dir_fd = file_data_new_simple(path);
+		FileData *dir_fd = file_data_new_dir(path);
 		tab_completion_append_to_history(pw->path_entry, path);
 
 		pan_layout_set_fd(pw, dir_fd);
--- a/src/remote.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/remote.c	Fri Sep 30 23:02:26 2011 +0200
@@ -411,7 +411,7 @@
 static void gr_slideshow_start_rec(const gchar *text, GIOChannel *channel, gpointer data)
 {
 	GList *list;
-	FileData *dir_fd = file_data_new_simple(text);
+	FileData *dir_fd = file_data_new_dir(text);
 	list = filelist_recursive(dir_fd);
 	file_data_unref(dir_fd);
 	if (!list) return;
--- a/src/search.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/search.c	Fri Sep 30 23:02:26 2011 +0200
@@ -2006,7 +2006,7 @@
 			path = fd->path + strlen(sd->search_dir_fd->path);
 			if (path != fd->path)
 				{
-				FileData *dir_fd = file_data_new_simple(path);
+				FileData *dir_fd = file_data_new_dir(path);
 				success = filelist_read(dir_fd, &list, NULL);
 				file_data_unref(dir_fd);
 				}
@@ -2208,7 +2208,7 @@
 		if (isdir(path))
 			{
 			file_data_unref(sd->search_dir_fd);
-			sd->search_dir_fd = file_data_new_simple(path);
+			sd->search_dir_fd = file_data_new_dir(path);
 
 			tab_completion_append_to_history(sd->path_entry, sd->search_dir_fd->path);
 
@@ -2227,7 +2227,7 @@
 		{
 		/* search metadata */
 		file_data_unref(sd->search_dir_fd);
-		sd->search_dir_fd = file_data_new_simple(get_metadata_cache_dir());
+		sd->search_dir_fd = file_data_new_dir(get_metadata_cache_dir());
 		search_start(sd);
 		}
 	else if (sd->search_type == SEARCH_MATCH_CONTAINS)
--- a/src/thumb.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/thumb.c	Fri Sep 30 23:02:26 2011 +0200
@@ -27,7 +27,7 @@
 
 
 static void thumb_loader_error_cb(ImageLoader *il, gpointer data);
-static void thumb_loader_setup(ThumbLoader *tl, const gchar *path);
+static void thumb_loader_setup(ThumbLoader *tl, FileData *fd);
 
 static GdkPixbuf *get_xv_thumbnail(gchar *thumb_filename, gint max_w, gint max_h);
 
@@ -161,7 +161,7 @@
 		DEBUG_1("thumbnail size mismatch, regenerating: %s", tl->fd->path);
 		tl->cache_hit = FALSE;
 
-		thumb_loader_setup(tl, tl->fd->path);
+		thumb_loader_setup(tl, tl->fd);
 	
 		g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
 
@@ -262,12 +262,10 @@
 	if (!tl->idle_done_id) tl->idle_done_id = g_idle_add(thumb_loader_done_delay_cb, tl);
 }
 
-static void thumb_loader_setup(ThumbLoader *tl, const gchar *path)
+static void thumb_loader_setup(ThumbLoader *tl, FileData *fd)
 {
-	FileData *fd = file_data_new_simple(path);
 	image_loader_free(tl->il);
 	tl->il = image_loader_new(fd);
-	file_data_unref(fd);
 	image_loader_set_priority(tl->il, G_PRIORITY_LOW);
 
 	/* this will speed up jpegs by up to 3x in some cases */
@@ -377,13 +375,15 @@
 
 	if (cache_path)
 		{
-		thumb_loader_setup(tl, cache_path);
+		FileData *fd = file_data_new_no_grouping(cache_path);
+		thumb_loader_setup(tl, fd);
+		file_data_unref(fd);
 		g_free(cache_path);
 		tl->cache_hit = TRUE;
 		}
 	else
 		{
-		thumb_loader_setup(tl, tl->fd->path);
+		thumb_loader_setup(tl, tl->fd);
 		}
 
 	g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
@@ -395,7 +395,7 @@
 			tl->cache_hit = FALSE;
 			log_printf("%s", _("Thumbnail image in cache failed to load, trying to recreate.\n"));
 
-			thumb_loader_setup(tl, tl->fd->path);
+			thumb_loader_setup(tl, tl->fd);
 			g_signal_connect(G_OBJECT(tl->il), "done", (GCallback)thumb_loader_done_cb, tl);
 			if (image_loader_start(tl->il)) return TRUE;
 			}
--- a/src/thumb_standard.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/thumb_standard.c	Fri Sep 30 23:02:26 2011 +0200
@@ -66,7 +66,6 @@
 
 static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data);
 static gint thumb_loader_std_setup(ThumbLoaderStd *tl, FileData *fd);
-static gint thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path);
 
 
 ThumbLoaderStd *thumb_loader_std_new(gint width, gint height)
@@ -514,10 +513,16 @@
 		if (!tl->thumb_path_local)
 			{
 			tl->thumb_path = thumb_loader_std_cache_path(tl, TRUE, NULL, FALSE);
-			if (isfile(tl->thumb_path) && thumb_loader_std_setup_path(tl, tl->thumb_path))
+			if (isfile(tl->thumb_path))
 				{
-				tl->thumb_path_local = TRUE;
-				return TRUE;
+				FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+				if (thumb_loader_std_setup(tl, fd))
+					{
+					file_data_unref(fd);
+					tl->thumb_path_local = TRUE;
+					return TRUE;
+					}
+				file_data_unref(fd);
 				}
 
 			g_free(tl->thumb_path);
@@ -629,14 +634,6 @@
 	return FALSE;
 }
 
-static gboolean thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path)
-{
-	FileData *fd = file_data_new_simple(path);
-	gboolean ret = thumb_loader_std_setup(tl, fd);
-	file_data_unref(fd);
-	return ret;
-}
-
 /*
  * Note: Currently local_cache only specifies where to save a _new_ thumb, if
  *       a valid existing thumb is found anywhere the local thumb will not be created.
@@ -689,7 +686,16 @@
 		tl->thumb_path_local = FALSE;
 
 		found = isfile(tl->thumb_path);
-		if (found && thumb_loader_std_setup_path(tl, tl->thumb_path)) return TRUE;
+		if (found)
+			{
+			FileData *fd = file_data_new_no_grouping(tl->thumb_path);
+			if (thumb_loader_std_setup(tl, fd))
+				{
+				file_data_unref(fd);
+				return TRUE;
+				}
+			file_data_unref(fd);
+			}
 
 		if (thumb_loader_std_fail_check(tl) ||
 		    !thumb_loader_std_next_source(tl, found))
@@ -876,7 +882,8 @@
 	tv->func_valid = func_valid;
 	tv->data = data;
 
-	if (!thumb_loader_std_setup_path(tv->tl, thumb_path))
+	FileData *fd = file_data_new_no_grouping(thumb_path);
+	if (!thumb_loader_std_setup(tv->tl, fd))
 		{
 		tv->idle_id = g_idle_add(thumb_loader_std_thumb_file_validate_idle_cb, tv);
 		}
@@ -885,6 +892,7 @@
 		tv->idle_id = 0;
 		}
 
+	file_data_unref(fd);
 	return tv->tl;
 }
 
@@ -974,7 +982,6 @@
 			tm->tl->cache_enable = TRUE;
 			tm->tl->cache_hit = FALSE;
 			tm->tl->cache_local = FALSE;
-
 			file_data_unref(tm->tl->fd);
 			tm->tl->fd = file_data_new_simple(tm->dest);
 			tm->tl->source_mtime = strtol(mtime_str, NULL, 10);
--- a/src/trash.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/trash.c	Fri Sep 30 23:02:26 2011 +0200
@@ -37,7 +37,7 @@
 	gboolean warned = FALSE;
 	FileData *dir_fd;
 
-	dir_fd = file_data_new_simple(options->file_ops.safe_delete_path);
+	dir_fd = file_data_new_dir(options->file_ops.safe_delete_path);
 	if (!filelist_read(dir_fd, &list, NULL))
 		{
 		file_data_unref(dir_fd);
--- a/src/view_dir.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/view_dir.c	Fri Sep 30 23:02:26 2011 +0200
@@ -241,7 +241,7 @@
 	ViewDir *vd = data;
 	if (success)
 		{
-		FileData *fd = file_data_new_simple(new_path);
+		FileData *fd = file_data_new_dir(new_path);
 		GtkTreeIter iter;
 
 		if (vd_find_row(vd, fd, &iter))
@@ -435,7 +435,7 @@
 
 	if (vd->select_func)
 		{
-		FileData *fd = file_data_new_simple(path);
+		FileData *fd = file_data_new_dir(path);
 		vd->select_func(vd, fd, vd->select_data);
 		file_data_unref(fd);
 		}
@@ -561,7 +561,7 @@
 			break;
 		case DIRVIEW_TREE:
 			{
-			FileData *new_fd = file_data_new_simple(new_path);
+			FileData *new_fd = file_data_new_dir(new_path);
 			fd = vdtree_populate_path(vd, new_fd, TRUE, TRUE);
 			file_data_unref(new_fd);
 			}
@@ -1117,7 +1117,7 @@
 	if (vd->type == DIRVIEW_TREE)
 		{
 		GtkTreeIter iter;
-		FileData *base_fd = file_data_new_simple(base);
+		FileData *base_fd = file_data_new_dir(base);
 
 		if (vd_find_row(vd, base_fd, &iter))
 			{
--- a/src/view_dir_list.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/view_dir_list.c	Fri Sep 30 23:02:26 2011 +0200
@@ -159,7 +159,7 @@
 	if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
 		{
 		filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
-		fd = file_data_new_simple(filepath);
+		fd = file_data_new_dir(filepath);
 		VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
 		g_free(filepath);
 		}
@@ -167,7 +167,7 @@
 	if (options->file_filter.show_dot_directory)
 		{
 		filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
-		fd = file_data_new_simple(filepath);
+		fd = file_data_new_dir(filepath);
 		VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
 		g_free(filepath);
 	}
--- a/src/view_dir_tree.c	Fri Sep 30 10:54:32 2011 +0200
+++ b/src/view_dir_tree.c	Fri Sep 30 23:02:26 2011 +0200
@@ -495,16 +495,15 @@
 		if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
 			{
 			gchar *name8;
-			struct stat sbuf;
 
 			n++;
 
 			while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
 			name8 = g_strndup(target_fd->path, n);
 
-			if (stat_utf8(name8, &sbuf))
+			if (isdir(name8))
 				{
-				list = g_list_prepend(list, file_data_new_simple(name8));
+				list = g_list_prepend(list, file_data_new_dir(name8));
 				}
 
 			g_free(name8);
@@ -926,7 +925,7 @@
 	FileData *fd;
 
 
-	fd = file_data_new_simple(path);
+	fd = file_data_new_dir(path);
 	vdtree_add_by_data(vd, fd, NULL);
 
 	vdtree_expand_by_data(vd, fd, TRUE);