forked from enlightenment/efl
efret: Save whether cache changed in update file.
SVN revision: 62506
This commit is contained in:
parent
fa2a688b02
commit
f696cd74bd
|
@ -86,7 +86,7 @@
|
||||||
|
|
||||||
* Fixed uri encoding when opening files.
|
* Fixed uri encoding when opening files.
|
||||||
|
|
||||||
2011-08-16 sebastian Dransfeld
|
2011-08-16 Sebastian Dransfeld
|
||||||
|
|
||||||
* Always rebuild cache from scratch when needed, but rely on correct
|
* Always rebuild cache from scratch when needed, but rely on correct
|
||||||
spec behaviour to check for theme changes. This will considerably
|
spec behaviour to check for theme changes. This will considerably
|
||||||
|
@ -94,3 +94,7 @@
|
||||||
correctness of the cache when changes occur. For example didn't the
|
correctness of the cache when changes occur. For example didn't the
|
||||||
previous behaviour handle file removal gracefully.
|
previous behaviour handle file removal gracefully.
|
||||||
|
|
||||||
|
2011-08-16 Sebastian Dransfeld
|
||||||
|
|
||||||
|
* Save whether cache changed in update file, and propagate to update
|
||||||
|
event.
|
||||||
|
|
|
@ -487,8 +487,11 @@ main(int argc, char **argv)
|
||||||
tmpfd = open(file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
tmpfd = open(file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
||||||
if (tmpfd >= 0)
|
if (tmpfd >= 0)
|
||||||
{
|
{
|
||||||
|
char c = 'n';
|
||||||
|
|
||||||
efreet_fsetowner(tmpfd);
|
efreet_fsetowner(tmpfd);
|
||||||
if (write(tmpfd, "a", 1) != 1) perror("write");
|
if (changed) c = 'c';
|
||||||
|
if (write(tmpfd, &c, 1) != 1) perror("write");
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1102,8 +1102,11 @@ main(int argc, char **argv)
|
||||||
tmpfd = open(file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
tmpfd = open(file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
||||||
if (tmpfd >= 0)
|
if (tmpfd >= 0)
|
||||||
{
|
{
|
||||||
|
char c = 'n';
|
||||||
|
|
||||||
efreet_fsetowner(tmpfd);
|
efreet_fsetowner(tmpfd);
|
||||||
if (write(tmpfd, "a", 1) != 1) perror("write");
|
if (changed) c = 'c';
|
||||||
|
if (write(tmpfd, &c, 1) != 1) perror("write");
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ typedef struct _Efreet_Event_Cache_Update Efreet_Event_Cache_Update;
|
||||||
*/
|
*/
|
||||||
struct _Efreet_Event_Cache_Update
|
struct _Efreet_Event_Cache_Update
|
||||||
{
|
{
|
||||||
int dummy;
|
int changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -99,6 +99,7 @@ static Eina_Bool efreet_cache_check(Eet_File **ef, const char *path, int major);
|
||||||
static void *efreet_cache_close(Eet_File *ef);
|
static void *efreet_cache_close(Eet_File *ef);
|
||||||
|
|
||||||
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
||||||
|
static Eina_Bool cache_check_change(const char *path);
|
||||||
static void cache_update_cb(void *data, Ecore_File_Monitor *em,
|
static void cache_update_cb(void *data, Ecore_File_Monitor *em,
|
||||||
Ecore_File_Event event, const char *path);
|
Ecore_File_Event event, const char *path);
|
||||||
|
|
||||||
|
@ -1043,6 +1044,22 @@ cache_exe_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
cache_check_change(const char *path)
|
||||||
|
{
|
||||||
|
const char *data;
|
||||||
|
Eina_Bool changed = EINA_TRUE;
|
||||||
|
Eina_File *f;
|
||||||
|
|
||||||
|
f = eina_file_open(path, EINA_FALSE);
|
||||||
|
if (!f) return EINA_TRUE;
|
||||||
|
if (eina_file_size_get(f) < 1) return EINA_TRUE;
|
||||||
|
data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
||||||
|
if (*data == 'n') changed = EINA_FALSE;
|
||||||
|
eina_file_close(f);
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
Ecore_File_Event event, const char *path)
|
Ecore_File_Event event, const char *path)
|
||||||
|
@ -1061,7 +1078,9 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
{
|
{
|
||||||
ev = NEW(Efreet_Event_Cache_Update, 1);
|
ev = NEW(Efreet_Event_Cache_Update, 1);
|
||||||
if (!ev) goto error;
|
if (!ev) goto error;
|
||||||
|
ev->changed = 0;
|
||||||
|
if (cache_check_change(path))
|
||||||
|
{
|
||||||
IF_RELEASE(util_cache_names_key);
|
IF_RELEASE(util_cache_names_key);
|
||||||
IF_RELEASE(util_cache_hash_key);
|
IF_RELEASE(util_cache_hash_key);
|
||||||
|
|
||||||
|
@ -1087,6 +1106,8 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
}
|
}
|
||||||
|
|
||||||
util_cache = efreet_cache_close(util_cache);
|
util_cache = efreet_cache_close(util_cache);
|
||||||
|
ev->changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
|
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
|
||||||
/* TODO: Check if desktop_dirs_add exists, and rebuild cache if */
|
/* TODO: Check if desktop_dirs_add exists, and rebuild cache if */
|
||||||
|
@ -1095,7 +1116,9 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
{
|
{
|
||||||
ev = NEW(Efreet_Event_Cache_Update, 1);
|
ev = NEW(Efreet_Event_Cache_Update, 1);
|
||||||
if (!ev) goto error;
|
if (!ev) goto error;
|
||||||
|
ev->changed = 0;
|
||||||
|
if (cache_check_change(path))
|
||||||
|
{
|
||||||
IF_RELEASE(theme_name);
|
IF_RELEASE(theme_name);
|
||||||
|
|
||||||
/* Save all old caches */
|
/* Save all old caches */
|
||||||
|
@ -1125,6 +1148,8 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
icon_theme_cache = NULL;
|
icon_theme_cache = NULL;
|
||||||
icon_cache = NULL;
|
icon_cache = NULL;
|
||||||
fallback_cache = NULL;
|
fallback_cache = NULL;
|
||||||
|
ev->changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send event */
|
/* Send event */
|
||||||
ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, l);
|
ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, l);
|
||||||
|
@ -1261,6 +1286,8 @@ desktop_cache_update_free(void *data, void *ev)
|
||||||
int dangling = 0;
|
int dangling = 0;
|
||||||
|
|
||||||
d = data;
|
d = data;
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* All users should now had the chance to update their pointers, so we can now
|
* All users should now had the chance to update their pointers, so we can now
|
||||||
* free the old cache
|
* free the old cache
|
||||||
|
@ -1302,6 +1329,7 @@ desktop_cache_update_free(void *data, void *ev)
|
||||||
}
|
}
|
||||||
old_desktop_caches = eina_list_remove(old_desktop_caches, d);
|
old_desktop_caches = eina_list_remove(old_desktop_caches, d);
|
||||||
free(d);
|
free(d);
|
||||||
|
}
|
||||||
free(ev);
|
free(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue