diff options
author | daniel <daniel.mohns@posteo.de> | 2019-05-15 19:15:37 +0200 |
---|---|---|
committer | daniel <daniel.mohns@posteo.de> | 2019-05-15 19:15:37 +0200 |
commit | 03778dbd82653e687d8701bade56284f77c5ebd4 (patch) | |
tree | 95f020509b36f79c0f3a2a555bcec88611f8ba60 | |
parent | e9eb621a9282928173f8e81a903656e88ab83c42 (diff) | |
download | gnome-desktop-03778dbd82653e687d8701bade56284f77c5ebd4.tar.gz |
thumbnailer: Cleanup stale thumbnail directories
To correctly cleanup after thumbnail generation for inode/directory
objects we need to distinguish between files and directories. Then
cleanup with `g_rmdir` or `g_unlink` accordingly.
Also, we add a consistency condition when naming the temporary files, as
directories will be extention-less.
-rw-r--r-- | libgnome-desktop/gnome-desktop-thumbnail-script.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libgnome-desktop/gnome-desktop-thumbnail-script.c b/libgnome-desktop/gnome-desktop-thumbnail-script.c index 79419760..0aa26444 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail-script.c +++ b/libgnome-desktop/gnome-desktop-thumbnail-script.c @@ -719,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) @@ -797,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); |