summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-06 23:58:29 +0200
committerColin Walters <walters@verbum.org>2013-08-06 23:58:29 +0200
commit71c4ea67f7f135e0f00a0d97ba3583d4775c8165 (patch)
treef9b8b72d02becb4ae433e92d006ad60e3a5178f4
parent9e480cd6a97ac7d2bb6aef1f25f322d693cd8d8f (diff)
downloadostree-71c4ea67f7f135e0f00a0d97ba3583d4775c8165.tar.gz
core: Clean up temporary file creation
Use new libgsystem API, don't expose the repo's tmpdir.
m---------src/libgsystem0
-rw-r--r--src/libostree/ostree-core.c31
-rw-r--r--src/libostree/ostree-core.h8
-rw-r--r--src/libostree/ostree-fetcher.c8
-rw-r--r--src/libostree/ostree-repo-pull.c3
-rw-r--r--src/libostree/ostree-repo.c26
-rw-r--r--src/libostree/ostree-repo.h2
7 files changed, 11 insertions, 67 deletions
diff --git a/src/libgsystem b/src/libgsystem
-Subproject f56702ef40a5df056097d2e14ee0dac3614b744
+Subproject 3dee2f23ac34d1d5ce2ed8cbad14cb0596d2b57
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 1a1b396f..eef974aa 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -1365,37 +1365,6 @@ ostree_create_temp_file_from_input (GFile *dir,
}
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,
const char *suffix,
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 7a78e1ab..cc940e66 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -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,
diff --git a/src/libostree/ostree-fetcher.c b/src/libostree/ostree-fetcher.c
index f330150c..e1f3db2a 100644
--- a/src/libostree/ostree-fetcher.c
+++ b/src/libostree/ostree-fetcher.c
@@ -228,11 +228,9 @@ 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,
- NULL, &local_error))
+ 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);
g_simple_async_result_complete (pending->result);
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 83ff8c08..711fd31e 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -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)
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 226678ee..4ae2ba0f 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -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,10 +572,9 @@ 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,
- &temp_file, &temp_out,
- cancellable, error))
+ if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
+ &temp_file, &temp_out,
+ cancellable, error))
goto out;
temp_file_is_regular = TRUE;
@@ -633,10 +620,9 @@ 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,
- &raw_temp_file, &content_out,
- cancellable, error))
+ if (!gs_file_open_in_tmpdir (self->tmp_dir, 0644,
+ &raw_temp_file, &content_out,
+ cancellable, error))
goto out;
/* Don't make setuid files in the repository; all we want to preserve
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 8179f684..e67a6f39 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -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);