Commit 0fd185fa authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Make gtk-update-icon-cache not fall over leftover temp files

When called with the --force option, try to remove the .icon-theme.cache
file before giving up. This fixes rh#500163.
parent dc0dde99
...@@ -1438,6 +1438,7 @@ build_cache (const gchar *path) ...@@ -1438,6 +1438,7 @@ build_cache (const gchar *path)
struct utimbuf utime_buf; struct utimbuf utime_buf;
GList *directories = NULL; GList *directories = NULL;
int fd; int fd;
int retry_count = 0;
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
#else #else
...@@ -1450,8 +1451,15 @@ build_cache (const gchar *path) ...@@ -1450,8 +1451,15 @@ build_cache (const gchar *path)
tmp_cache_path = g_build_filename (path, "."CACHE_NAME, NULL); tmp_cache_path = g_build_filename (path, "."CACHE_NAME, NULL);
cache_path = g_build_filename (path, CACHE_NAME, NULL); cache_path = g_build_filename (path, CACHE_NAME, NULL);
opentmp:
if ((fd = g_open (tmp_cache_path, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | _O_BINARY, mode)) == -1) if ((fd = g_open (tmp_cache_path, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | _O_BINARY, mode)) == -1)
{ {
if (force_update && retry_count == 0)
{
retry_count++;
g_remove (tmp_cache_path);
goto opentmp;
}
g_printerr (_("Failed to open file %s : %s\n"), tmp_cache_path, g_strerror (errno)); g_printerr (_("Failed to open file %s : %s\n"), tmp_cache_path, g_strerror (errno));
exit (1); exit (1);
} }
...@@ -1497,7 +1505,7 @@ build_cache (const gchar *path) ...@@ -1497,7 +1505,7 @@ build_cache (const gchar *path)
if (!validate_file (tmp_cache_path)) if (!validate_file (tmp_cache_path))
{ {
g_printerr (_("The generated cache was invalid.\n")); g_printerr (_("The generated cache was invalid.\n"));
//g_unlink (tmp_cache_path); /*g_unlink (tmp_cache_path);*/
exit (1); exit (1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment