gtk2/gtk2-remove-empty-cache.patch

86 lines
2.6 KiB
Diff

Index: gtk/updateiconcache.c
================================================================================
--- gtk/updateiconcache.c
+++ gtk/updateiconcache.c
@@ -44,6 +44,7 @@
static gboolean quiet = FALSE;
static gboolean index_only = FALSE;
static gchar *var_name = "-";
+static gboolean remove_empty_cache = FALSE;
#define CACHE_NAME "icon-theme.cache"
@@ -1168,12 +1169,17 @@
directories = scan_directory (path, NULL, files, NULL, 0);
+ cache_path = g_build_filename (path, CACHE_NAME, NULL);
+
if (g_hash_table_size (files) == 0)
{
/* Empty table, just close and remove the file */
fclose (cache);
g_unlink (tmp_cache_path);
+ if (remove_empty_cache)
+ g_unlink (cache_path);
+ g_free (cache_path);
exit (0);
}
@@ -1187,10 +1193,10 @@
if (!retval)
{
g_unlink (tmp_cache_path);
+ g_free (cache_path);
exit (1);
}
- cache_path = g_build_filename (path, CACHE_NAME, NULL);
#ifdef G_OS_WIN32
if (g_file_test (cache_path, G_FILE_TEST_EXISTS))
@@ -1204,6 +1210,7 @@
g_strerror (errno),
cache_path);
g_unlink (cache_path);
+ g_free (cache_path);
bak_cache_path = NULL;
}
}
@@ -1215,6 +1222,7 @@
tmp_cache_path, cache_path,
g_strerror (errno));
g_unlink (tmp_cache_path);
+ g_free (cache_path);
#ifdef G_OS_WIN32
if (bak_cache_path != NULL)
if (g_rename (bak_cache_path, cache_path) == -1)
@@ -1233,12 +1241,17 @@
/* FIXME: What do do if an error occurs here? */
if (g_stat (path, &path_stat) < 0 ||
g_stat (cache_path, &cache_stat))
- exit (1);
+ {
+ g_free (cache_path);
+ exit (1);
+ }
utime_buf.actime = path_stat.st_atime;
utime_buf.modtime = cache_stat.st_mtime;
utime (path, &utime_buf);
+ g_free (cache_path);
+
if (!quiet)
g_printerr (_("Cache file created successfully.\n"));
}
@@ -1282,6 +1295,7 @@
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, N_("Overwrite an existing cache, even if uptodate"), NULL },
{ "ignore-theme-index", 't', 0, G_OPTION_ARG_NONE, &ignore_theme_index, N_("Don't check for the existence of index.theme"), NULL },
{ "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, N_("Don't include image data in the cache"), NULL },
+ { "remove-empty-cache", 'r', 0, G_OPTION_ARG_NONE, &remove_empty_cache, "Remove the cache file if there is nothing to cache", NULL },
{ "source", 'c', 0, G_OPTION_ARG_STRING, &var_name, N_("Output a C header file"), "NAME" },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Turn off verbose output"), NULL },
{ NULL }