core: Clean up temporary file creation

Use new libgsystem API, don't expose the repo's tmpdir.
This commit is contained in:
Colin Walters 2013-08-06 23:58:29 +02:00
parent 9e480cd6a9
commit 71c4ea67f7
7 changed files with 12 additions and 68 deletions

@ -1 +1 @@
Subproject commit f56702ef40a5df056097d2e14ee0dac3614b744c
Subproject commit 3dee2f23ac34d1d5ce2ed8cbad14cb0596d2b57f

View File

@ -1364,37 +1364,6 @@ ostree_create_temp_file_from_input (GFile *dir,
return ret;
}
gboolean
ostree_create_temp_regular_file (GFile *dir,
const char *prefix,
const char *suffix,
GFile **out_file,
GOutputStream **out_stream,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *ret_file = NULL;
gs_unref_object GOutputStream *ret_stream = NULL;
if (!ostree_create_temp_file_from_input (dir, prefix, suffix, NULL, NULL, NULL,
&ret_file, cancellable, error))
goto out;
if (out_stream)
{
ret_stream = (GOutputStream*)g_file_append_to (ret_file, 0, cancellable, error);
if (ret_stream == NULL)
goto out;
}
ret = TRUE;
ot_transfer_out_value(out_file, &ret_file);
ot_transfer_out_value(out_stream, &ret_stream);
out:
return ret;
}
gboolean
ostree_create_temp_dir (GFile *dir,
const char *prefix,

View File

@ -269,14 +269,6 @@ gboolean ostree_create_temp_file_from_input (GFile *dir,
GCancellable *cancellable,
GError **error);
gboolean ostree_create_temp_regular_file (GFile *dir,
const char *prefix,
const char *suffix,
GFile **out_file,
GOutputStream **out_stream,
GCancellable *cancellable,
GError **error);
gboolean ostree_create_temp_dir (GFile *dir,
const char *prefix,
const char *suffix,

View File

@ -228,10 +228,8 @@ on_request_sent (GObject *object,
pending->content_length = soup_request_get_content_length (pending->request);
/* TODO - make this async */
if (!ostree_create_temp_regular_file (pending->self->tmpdir,
NULL, NULL,
&pending->tmpfile,
&pending->out_stream,
if (!gs_file_open_in_tmpdir (pending->self->tmpdir, 0644,
&pending->tmpfile, &pending->out_stream,
NULL, &local_error))
{
g_simple_async_result_take_error (pending->result, local_error);

View File

@ -68,6 +68,7 @@
#include "config.h"
#include "ostree.h"
#include "ostree-repo-private.h"
#include "ostree-fetcher.h"
#include "otutil.h"
@ -1225,7 +1226,7 @@ ostree_repo_pull (OstreeRepo *repo,
if (tls_permissive)
fetcher_flags |= OSTREE_FETCHER_FLAGS_TLS_PERMISSIVE;
pull_data->fetcher = ostree_fetcher_new (ostree_repo_get_tmpdir (pull_data->repo),
pull_data->fetcher = ostree_fetcher_new (pull_data->repo->tmp_dir,
fetcher_flags);
if (!pull_data->base_uri)

View File

@ -387,18 +387,6 @@ ostree_repo_get_path (OstreeRepo *self)
return self->repodir;
}
/**
* ostree_repo_get_tmpdir:
* @self:
*
* Returns: (transfer none): Path to temporary directory
*/
GFile *
ostree_repo_get_tmpdir (OstreeRepo *self)
{
return self->tmp_dir;
}
OstreeRepoMode
ostree_repo_get_mode (OstreeRepo *self)
{
@ -584,8 +572,7 @@ stage_object (OstreeRepo *self,
gs_unref_object GConverter *zlib_compressor = NULL;
gs_unref_object GOutputStream *compressed_out_stream = NULL;
if (!ostree_create_temp_regular_file (self->tmp_dir,
ostree_object_type_to_string (objtype), NULL,
if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
&temp_file, &temp_out,
cancellable, error))
goto out;
@ -633,8 +620,7 @@ stage_object (OstreeRepo *self,
guint32 src_mode;
guint32 target_mode;
if (!ostree_create_temp_regular_file (self->tmp_dir,
ostree_object_type_to_string (objtype), NULL,
if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
&raw_temp_file, &content_out,
cancellable, error))
goto out;

View File

@ -53,8 +53,6 @@ gboolean ostree_repo_mode_from_string (const char *mode,
OstreeRepoMode ostree_repo_get_mode (OstreeRepo *self);
GFile * ostree_repo_get_tmpdir (OstreeRepo *self);
GKeyFile * ostree_repo_get_config (OstreeRepo *self);
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);