From 0f1c723ad2fe48a0f22e32619985f93ebb2e02ef Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 25 Oct 2009 15:04:20 +0000 Subject: libdocument: Clean up temp file handling t push origin HEAD:master Make sure we can cope with not being able to create our temp directory. Bug #595372. --- (limited to 'backend/comics') diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c index fbe6ba0..b53d513 100644 --- a/backend/comics/comics-document.c +++ b/backend/comics/comics-document.c @@ -205,32 +205,20 @@ comics_generate_command_lines (ComicsDocument *comics_document, comics_document->regex_arg = command_usage_def[type].regex_arg; comics_document->offset = command_usage_def[type].offset; if (command_usage_def[type].decompress_tmp) { - comics_document->dir = ev_tmp_directory (NULL); - comics_document->decompress_tmp = + comics_document->dir = ev_mkdtemp ("comics.XXXXXX", error); + if (comics_document->dir == NULL) + return FALSE; + + /* unrar-free can't create directories, but ev_mkdtemp already created the dir */ + + comics_document->decompress_tmp = g_strdup_printf (command_usage_def[type].decompress_tmp, comics_document->selected_command, quoted_file, comics_document->dir); g_free (quoted_file); - /* unrar-free can't create directories so we do it on its - * behalf */ - if (type == GNAUNRAR) { - if (g_mkdir_with_parents (comics_document->dir, 0700) != - 0) { - int errsv = errno; - g_set_error (error, - EV_DOCUMENT_ERROR, - EV_DOCUMENT_ERROR_INVALID, - _("Failed to create a temporary " - "directory.")); - g_warning ("Failed to create directory %s: %s", - comics_document->dir, - g_strerror (errsv)); - - return FALSE; - } - } - if (!comics_decompress_temp_dir (comics_document->decompress_tmp, + + if (!comics_decompress_temp_dir (comics_document->decompress_tmp, comics_document->selected_command, error)) return FALSE; else @@ -713,7 +701,6 @@ comics_document_finalize (GObject *object) g_warning (_("There was an error deleting ā€œ%sā€."), comics_document->dir); g_free (comics_document->dir); - g_remove (ev_tmp_dir ()); } if (comics_document->page_names) { -- cgit v0.9.1