[sushi] pdf-loader: save the converted document in $XDG_CACHE_HOME/sushi
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] pdf-loader: save the converted document in $XDG_CACHE_HOME/sushi
- Date: Thu, 12 May 2011 19:20:35 +0000 (UTC)
commit ab40a4356b73bd4463bf188db5eb7195c5433843
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu May 12 15:19:47 2011 -0400
pdf-loader: save the converted document in $XDG_CACHE_HOME/sushi
Instead of /tmp, which is world-readable.
src/libsushi/sushi-pdf-loader.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/libsushi/sushi-pdf-loader.c b/src/libsushi/sushi-pdf-loader.c
index aa59a51..e4ee88d 100644
--- a/src/libsushi/sushi-pdf-loader.c
+++ b/src/libsushi/sushi-pdf-loader.c
@@ -74,7 +74,7 @@ unoconv_child_watch_cb (GPid pid,
static void
load_openoffice (SushiPdfLoader *self)
{
- gchar *doc_path, *pdf_path, *tmp_name;
+ gchar *doc_path, *pdf_path, *tmp_name, *tmp_path;
GFile *file;
gboolean res;
gchar *cmd;
@@ -88,13 +88,17 @@ load_openoffice (SushiPdfLoader *self)
doc_path = g_file_get_path (file);
g_object_unref (file);
- tmp_name = g_strconcat ("sushi-", g_get_user_name (), "-tmp.pdf", NULL);
+ tmp_name = g_strdup_printf ("sushi-%d.pdf", getpid ());
+ tmp_path = g_build_filename (g_get_user_cache_dir (), "sushi", NULL);
self->priv->pdf_path = pdf_path =
- g_build_filename (g_get_tmp_dir (), tmp_name, NULL);
+ g_build_filename (tmp_path, tmp_name, NULL);
+ g_mkdir_with_parents (tmp_path, 0700);
+
cmd = g_strdup_printf ("unoconv -f pdf -o %s %s", pdf_path, doc_path);
g_free (doc_path);
g_free (tmp_name);
+ g_free (tmp_path);
res = g_shell_parse_argv (cmd, &argc, &argv, &error);
g_free (cmd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]