diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-07-20 17:42:10 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-07-20 17:42:10 +0000 |
commit | 066bb1b8f64a3b76a6600738e257cc44f439b651 (patch) | |
tree | 465c203994f9aedb6d8b4c0946410f2a81cab47d /gtk/xdgmime | |
parent | 02471fdddc4bb66fa4fff020c1b79693bf1fc419 (diff) | |
download | gtk+-066bb1b8f64a3b76a6600738e257cc44f439b651.tar.gz |
Fix a thinko that leads to constantly reloading the mime data if a
2006-07-20 Matthias Clasen <mclasen@redhat.com>
Fix a thinko that leads to constantly reloading
the mime data if a mime.cache is present. Patch
by Yevgen Muntyan, bugs.freedesktop.org #7495
* xdgmime.c (xdg_check_dir): Look for mime.cache first.
(xdg_check_file): Report existance of the file separately.
Diffstat (limited to 'gtk/xdgmime')
-rw-r--r-- | gtk/xdgmime/ChangeLog | 9 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmime.c | 39 |
2 files changed, 34 insertions, 14 deletions
diff --git a/gtk/xdgmime/ChangeLog b/gtk/xdgmime/ChangeLog index 5b25f9ff31..9d21c39273 100644 --- a/gtk/xdgmime/ChangeLog +++ b/gtk/xdgmime/ChangeLog @@ -1,5 +1,14 @@ 2006-07-20 Matthias Clasen <mclasen@redhat.com> + Fix a thinko that leads to constantly reloading + the mime data if a mime.cache is present. Patch + by Yevgen Muntyan, bugs.freedesktop.org #7495 + + * xdgmime.c (xdg_check_dir): Look for mime.cache first. + (xdg_check_file): Report existance of the file separately. + +2006-07-20 Matthias Clasen <mclasen@redhat.com> + * xdgmime.c (xdg_mime_shutdown): Unref the caches. Patch by Yevgen Muntyan, bugs.freedesktop.org #7496 diff --git a/gtk/xdgmime/xdgmime.c b/gtk/xdgmime/xdgmime.c index 23be62b040..1d2007cb78 100644 --- a/gtk/xdgmime/xdgmime.c +++ b/gtk/xdgmime/xdgmime.c @@ -281,7 +281,8 @@ xdg_run_command_on_dirs (XdgDirectoryFunc func, * FIXME: This doesn't protect against permission changes. */ static int -xdg_check_file (const char *file_path) +xdg_check_file (const char *file_path, + int *exists) { struct stat st; @@ -290,6 +291,9 @@ xdg_check_file (const char *file_path) { XdgDirTimeList *list; + if (exists) + *exists = TRUE; + for (list = dir_time_list; list; list = list->next) { if (! strcmp (list->directory_name, file_path) && @@ -306,6 +310,9 @@ xdg_check_file (const char *file_path) return TRUE; } + if (exists) + *exists = FALSE; + return FALSE; } @@ -313,26 +320,30 @@ static int xdg_check_dir (const char *directory, int *invalid_dir_list) { - int invalid; + int invalid, exists; char *file_name; assert (directory != NULL); - /* Check the globs file */ - file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1); - strcpy (file_name, directory); strcat (file_name, "/mime/globs"); - invalid = xdg_check_file (file_name); + /* Check the mime.cache file */ + file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1); + strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache"); + invalid = xdg_check_file (file_name, &exists); free (file_name); if (invalid) { *invalid_dir_list = TRUE; return TRUE; } + else if (exists) + { + return FALSE; + } - /* Check the magic file */ - file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1); - strcpy (file_name, directory); strcat (file_name, "/mime/magic"); - invalid = xdg_check_file (file_name); + /* Check the globs file */ + file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1); + strcpy (file_name, directory); strcat (file_name, "/mime/globs"); + invalid = xdg_check_file (file_name, NULL); free (file_name); if (invalid) { @@ -340,10 +351,10 @@ xdg_check_dir (const char *directory, return TRUE; } - /* Check the mime.cache file */ - file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1); - strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache"); - invalid = xdg_check_file (file_name); + /* Check the magic file */ + file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1); + strcpy (file_name, directory); strcat (file_name, "/mime/magic"); + invalid = xdg_check_file (file_name, NULL); free (file_name); if (invalid) { |