Check the timestamps on .desktop files to see if the cache is still valid.

The entire applicition caching system will be rewritten soon, so
consider this a temporary fix.


SVN revision: 25437
This commit is contained in:
David Walter Seikel 2006-09-04 10:57:42 +00:00
parent 9bd616534c
commit 60a847ab41
5 changed files with 43 additions and 18 deletions

View File

@ -2,6 +2,8 @@
# define _ECORE_DESKTOP_H
#include <Ecore_Data.h>
#include <sys/types.h>
/**
* @file Ecore_Desktop.h
@ -56,6 +58,8 @@ struct _Ecore_Desktop
char *startup;
char *window_class;
int allocated; /* FIXME: NoDisplay, Hidden */
/* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
time_t mtime; /* For checking if the cache is valid. */
};
typedef struct _Ecore_Desktop Ecore_Desktop;

View File

@ -1,13 +1,13 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "Ecore_Desktop.h"
#include "ecore_desktop_private.h"
#include <ctype.h>
#include <sys/stat.h>
Ecore_List *ecore_desktop_paths_config = NULL;
Ecore_List *ecore_desktop_paths_menus = NULL;
Ecore_List *ecore_desktop_paths_directories = NULL;
@ -165,8 +165,23 @@ Ecore_Desktop *
ecore_desktop_get(const char *file, const char *lang)
{
Ecore_Desktop *result;
struct stat st;
int stated = 0;
result = (Ecore_Desktop *) ecore_hash_get(desktop_cache, (char *) file);
/* Check if the cache is still valid. */
if (result)
{
if (stat(result->original_path, &st) >= 0)
{
if(st.st_mtime > result->mtime)
{
ecore_hash_remove(desktop_cache, result->original_path);
result = NULL;
stated = 1;
}
}
}
if (!result)
{
result = calloc(1, sizeof(Ecore_Desktop));
@ -176,6 +191,12 @@ ecore_desktop_get(const char *file, const char *lang)
if (lang)
result->original_lang = strdup(lang);
result->data = ecore_desktop_ini_get(result->original_path);
/* Timestamp the cache, and no need to stat the file twice if the cache was stale. */
if ((stated) || (stat(result->original_path, &st) >= 0))
{
result->mtime = st.st_mtime;
stated = 1;
}
if (result->data)
{
result->group =

View File

@ -6,16 +6,16 @@
* optomize into "ugly but fast".
*
*/
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libgen.h>
#include <Ecore.h>
#include "Ecore_Desktop.h"
#include "ecore_desktop_private.h"
#include <dirent.h>
#include <sys/stat.h>
#include <libgen.h>
//#define DEBUG 1
struct _ecore_desktop_menu_expand_apps_data

View File

@ -6,17 +6,17 @@
* excess directory from the paths.
*/
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libgen.h>
#include <strings.h>
#include <Ecore.h>
#include "Ecore_Desktop.h"
#include "ecore_desktop_private.h"
#include <dirent.h>
#include <sys/stat.h>
#include <libgen.h>
#include <strings.h>
/* This really slows things down and no doubt drags in some KDE bloat at start up.
* To work around this, I add a few extra things to try in the _ecore_desktop_paths_get()

View File

@ -1,11 +1,11 @@
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "Ecore_Desktop.h"
#include "ecore_desktop_private.h"
#include <fcntl.h>
#include <ctype.h>
#include <sys/stat.h>
/** xmlame.c Extensively Mocked Language Approximately Mangled for Enlightenment.
*
* This is NOT a real XML parser. There were a few ways we could go when it came