Free caches in xdg_mime_shutdown(); do not reload database every five seconds.
https://bugs.freedesktop.org/show_bug.cgi?id=7495 https://bugs.freedesktop.org/show_bug.cgi?id=7496master
parent
ec7492dcae
commit
bd6f42a872
|
@ -291,16 +291,16 @@
|
||||||
</kdevdoctreeview>
|
</kdevdoctreeview>
|
||||||
<kdevfilecreate>
|
<kdevfilecreate>
|
||||||
<filetypes>
|
<filetypes>
|
||||||
<type icon="source" ext="g" create="template" name="GAP source" >
|
<type icon="source" ext="g" name="GAP source" create="template" >
|
||||||
<descr>A new empty GAP source file</descr>
|
<descr>A new empty GAP source file</descr>
|
||||||
</type>
|
</type>
|
||||||
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
|
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
|
||||||
<descr>A new empty C++ file.</descr>
|
<descr>A new empty C++ file.</descr>
|
||||||
</type>
|
</type>
|
||||||
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
|
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
|
||||||
<descr>A new empty header file for C/C++.</descr>
|
<descr>A new empty header file for C/C++.</descr>
|
||||||
</type>
|
</type>
|
||||||
<type icon="source_c" ext="c" create="template" name="C Source" >
|
<type icon="source_c" ext="c" name="C Source" create="template" >
|
||||||
<descr>A new empty C file.</descr>
|
<descr>A new empty C file.</descr>
|
||||||
</type>
|
</type>
|
||||||
</filetypes>
|
</filetypes>
|
||||||
|
|
|
@ -281,7 +281,8 @@ xdg_run_command_on_dirs (XdgDirectoryFunc func,
|
||||||
* FIXME: This doesn't protect against permission changes.
|
* FIXME: This doesn't protect against permission changes.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xdg_check_file (const char *file_path)
|
xdg_check_file (const char *file_path,
|
||||||
|
int *exists)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -290,6 +291,9 @@ xdg_check_file (const char *file_path)
|
||||||
{
|
{
|
||||||
XdgDirTimeList *list;
|
XdgDirTimeList *list;
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
*exists = TRUE;
|
||||||
|
|
||||||
for (list = dir_time_list; list; list = list->next)
|
for (list = dir_time_list; list; list = list->next)
|
||||||
{
|
{
|
||||||
if (! strcmp (list->directory_name, file_path) &&
|
if (! strcmp (list->directory_name, file_path) &&
|
||||||
|
@ -303,9 +307,12 @@ xdg_check_file (const char *file_path)
|
||||||
return (list->checked != XDG_CHECKED_VALID);
|
return (list->checked != XDG_CHECKED_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
*exists = FALSE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,15 +320,28 @@ static int
|
||||||
xdg_check_dir (const char *directory,
|
xdg_check_dir (const char *directory,
|
||||||
int *invalid_dir_list)
|
int *invalid_dir_list)
|
||||||
{
|
{
|
||||||
int invalid;
|
int invalid, exists;
|
||||||
char *file_name;
|
char *file_name;
|
||||||
|
|
||||||
assert (directory != NULL);
|
assert (directory != NULL);
|
||||||
|
|
||||||
|
/* 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 globs file */
|
/* Check the globs file */
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
||||||
invalid = xdg_check_file (file_name);
|
invalid = xdg_check_file (file_name, NULL);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
if (invalid)
|
if (invalid)
|
||||||
{
|
{
|
||||||
|
@ -332,18 +352,7 @@ xdg_check_dir (const char *directory,
|
||||||
/* Check the magic file */
|
/* Check the magic file */
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
||||||
invalid = xdg_check_file (file_name);
|
invalid = xdg_check_file (file_name, NULL);
|
||||||
free (file_name);
|
|
||||||
if (invalid)
|
|
||||||
{
|
|
||||||
*invalid_dir_list = TRUE;
|
|
||||||
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);
|
|
||||||
free (file_name);
|
free (file_name);
|
||||||
if (invalid)
|
if (invalid)
|
||||||
{
|
{
|
||||||
|
@ -584,6 +593,16 @@ xdg_mime_shutdown (void)
|
||||||
parent_list = NULL;
|
parent_list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_xdg_mime_caches)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < n_caches; ++i)
|
||||||
|
_xdg_mime_cache_unref (_xdg_mime_caches[i]);
|
||||||
|
free (_xdg_mime_caches);
|
||||||
|
_xdg_mime_caches = NULL;
|
||||||
|
n_caches = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (list = callback_list; list; list = list->next)
|
for (list = callback_list; list; list = list->next)
|
||||||
(list->callback) (list->data);
|
(list->callback) (list->data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue