core: Clean up temporary file creation
Use new libgsystem API, don't expose the repo's tmpdir.
This commit is contained in:
parent
9e480cd6a9
commit
71c4ea67f7
|
|
@ -1 +1 @@
|
||||||
Subproject commit f56702ef40a5df056097d2e14ee0dac3614b744c
|
Subproject commit 3dee2f23ac34d1d5ce2ed8cbad14cb0596d2b57f
|
||||||
|
|
@ -1364,37 +1364,6 @@ ostree_create_temp_file_from_input (GFile *dir,
|
||||||
return ret;
|
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
|
gboolean
|
||||||
ostree_create_temp_dir (GFile *dir,
|
ostree_create_temp_dir (GFile *dir,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
|
|
|
||||||
|
|
@ -269,14 +269,6 @@ gboolean ostree_create_temp_file_from_input (GFile *dir,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
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,
|
gboolean ostree_create_temp_dir (GFile *dir,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
|
|
|
||||||
|
|
@ -228,11 +228,9 @@ on_request_sent (GObject *object,
|
||||||
pending->content_length = soup_request_get_content_length (pending->request);
|
pending->content_length = soup_request_get_content_length (pending->request);
|
||||||
|
|
||||||
/* TODO - make this async */
|
/* TODO - make this async */
|
||||||
if (!ostree_create_temp_regular_file (pending->self->tmpdir,
|
if (!gs_file_open_in_tmpdir (pending->self->tmpdir, 0644,
|
||||||
NULL, NULL,
|
&pending->tmpfile, &pending->out_stream,
|
||||||
&pending->tmpfile,
|
NULL, &local_error))
|
||||||
&pending->out_stream,
|
|
||||||
NULL, &local_error))
|
|
||||||
{
|
{
|
||||||
g_simple_async_result_take_error (pending->result, local_error);
|
g_simple_async_result_take_error (pending->result, local_error);
|
||||||
g_simple_async_result_complete (pending->result);
|
g_simple_async_result_complete (pending->result);
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "ostree.h"
|
#include "ostree.h"
|
||||||
|
#include "ostree-repo-private.h"
|
||||||
#include "ostree-fetcher.h"
|
#include "ostree-fetcher.h"
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
|
|
||||||
|
|
@ -1225,7 +1226,7 @@ ostree_repo_pull (OstreeRepo *repo,
|
||||||
if (tls_permissive)
|
if (tls_permissive)
|
||||||
fetcher_flags |= OSTREE_FETCHER_FLAGS_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);
|
fetcher_flags);
|
||||||
|
|
||||||
if (!pull_data->base_uri)
|
if (!pull_data->base_uri)
|
||||||
|
|
|
||||||
|
|
@ -387,18 +387,6 @@ ostree_repo_get_path (OstreeRepo *self)
|
||||||
return self->repodir;
|
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
|
OstreeRepoMode
|
||||||
ostree_repo_get_mode (OstreeRepo *self)
|
ostree_repo_get_mode (OstreeRepo *self)
|
||||||
{
|
{
|
||||||
|
|
@ -584,10 +572,9 @@ stage_object (OstreeRepo *self,
|
||||||
gs_unref_object GConverter *zlib_compressor = NULL;
|
gs_unref_object GConverter *zlib_compressor = NULL;
|
||||||
gs_unref_object GOutputStream *compressed_out_stream = NULL;
|
gs_unref_object GOutputStream *compressed_out_stream = NULL;
|
||||||
|
|
||||||
if (!ostree_create_temp_regular_file (self->tmp_dir,
|
if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
|
||||||
ostree_object_type_to_string (objtype), NULL,
|
&temp_file, &temp_out,
|
||||||
&temp_file, &temp_out,
|
cancellable, error))
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
temp_file_is_regular = TRUE;
|
temp_file_is_regular = TRUE;
|
||||||
|
|
||||||
|
|
@ -633,10 +620,9 @@ stage_object (OstreeRepo *self,
|
||||||
guint32 src_mode;
|
guint32 src_mode;
|
||||||
guint32 target_mode;
|
guint32 target_mode;
|
||||||
|
|
||||||
if (!ostree_create_temp_regular_file (self->tmp_dir,
|
if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
|
||||||
ostree_object_type_to_string (objtype), NULL,
|
&raw_temp_file, &content_out,
|
||||||
&raw_temp_file, &content_out,
|
cancellable, error))
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Don't make setuid files in the repository; all we want to preserve
|
/* Don't make setuid files in the repository; all we want to preserve
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,6 @@ gboolean ostree_repo_mode_from_string (const char *mode,
|
||||||
|
|
||||||
OstreeRepoMode ostree_repo_get_mode (OstreeRepo *self);
|
OstreeRepoMode ostree_repo_get_mode (OstreeRepo *self);
|
||||||
|
|
||||||
GFile * ostree_repo_get_tmpdir (OstreeRepo *self);
|
|
||||||
|
|
||||||
GKeyFile * ostree_repo_get_config (OstreeRepo *self);
|
GKeyFile * ostree_repo_get_config (OstreeRepo *self);
|
||||||
|
|
||||||
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);
|
GKeyFile * ostree_repo_copy_config (OstreeRepo *self);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue