summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gnome-desktop/gnome-desktop-thumbnail-script.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gnome-desktop/gnome-desktop-thumbnail-script.c b/src/gnome-desktop/gnome-desktop-thumbnail-script.c
index 8e8b87653..0aa26444a 100644
--- a/src/gnome-desktop/gnome-desktop-thumbnail-script.c
+++ b/src/gnome-desktop/gnome-desktop-thumbnail-script.c
@@ -149,7 +149,9 @@ get_extension (const char *path)
basename = g_path_get_basename (path);
p = strrchr (basename, '.');
- if (p == NULL)
+ if (g_file_test (path, G_FILE_TEST_IS_DIR) ||
+ !p ||
+ p == basename) /* Leading periods on the basename are ignored. */
return NULL;
return g_strdup (p + 1);
}
@@ -717,7 +719,10 @@ script_exec_free (ScriptExec *exec)
g_free (exec->infile);
if (exec->infile_tmp)
{
- g_unlink (exec->infile_tmp);
+ if (g_file_test (exec->infile_tmp, G_FILE_TEST_IS_DIR))
+ g_rmdir (exec->infile_tmp);
+ else
+ g_unlink (exec->infile_tmp);
g_free (exec->infile_tmp);
}
if (exec->outfile)
@@ -795,7 +800,12 @@ script_exec_new (const char *uri,
}
exec->outfile = g_build_filename (exec->outdir, "gnome-desktop-thumbnailer.png", NULL);
ext = get_extension (exec->infile);
- infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail.%s", ext);
+
+ if (ext)
+ infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail.%s", ext);
+ else
+ infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail");
+
exec->infile_tmp = g_build_filename (exec->outdir, infile, NULL);
exec->s_infile = g_build_filename ("/tmp/", infile, NULL);