core: Finish making object path API private
This allows us to more easily change the internals later.
This commit is contained in:
1 parent
0dec1b287c
commit
9e480cd6a9
8 files changed
+186
-122
No files matched your search
@@ -186,7 +186,7 @@ find_loose_for_checkout (OstreeRepo *self,
|
||||
switch (self->mode)
|
||||
{
|
||||
case OSTREE_REPO_MODE_BARE:
|
||||
path = ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
path = _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
break;
|
||||
case OSTREE_REPO_MODE_ARCHIVE:
|
||||
path = _ostree_repo_get_archive_content_path (self, checksum);
|
||||
|
||||
@@ -73,6 +73,11 @@ GFile *
|
||||
_ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||
const char *checksum);
|
||||
|
||||
GFile *
|
||||
_ostree_repo_get_object_path (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
OstreeObjectType type);
|
||||
|
||||
gboolean
|
||||
_ostree_repo_stage_directory_meta (OstreeRepo *self,
|
||||
GFileInfo *file_info,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ostree.h"
|
||||
#include "ostree-repo-private.h"
|
||||
#include "otutil.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -49,7 +49,7 @@ maybe_prune_loose_object (OtPruneData *data,
|
||||
|
||||
key = ostree_object_name_serialize (checksum, objtype);
|
||||
|
||||
objf = ostree_repo_get_object_path (data->repo, checksum, objtype);
|
||||
objf = _ostree_repo_get_object_path (data->repo, checksum, objtype);
|
||||
|
||||
if (!g_hash_table_lookup_extended (data->reachable, key, NULL, NULL))
|
||||
{
|
||||
|
||||
+63
-18
@@ -426,7 +426,7 @@ GFile *
|
||||
_ostree_repo_get_file_object_path (OstreeRepo *self,
|
||||
const char *checksum)
|
||||
{
|
||||
return ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
return _ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
|
||||
}
|
||||
|
||||
GFile *
|
||||
@@ -493,7 +493,7 @@ commit_loose_object_trusted (OstreeRepo *self,
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *dest_file = NULL;
|
||||
|
||||
dest_file = ostree_repo_get_object_path (self, checksum, objtype);
|
||||
dest_file = _ostree_repo_get_object_path (self, checksum, objtype);
|
||||
|
||||
if (!commit_loose_object_impl (self, tempfile_path, dest_file, is_regular,
|
||||
cancellable, error))
|
||||
@@ -1276,22 +1276,10 @@ _ostree_repo_stage_directory_meta (OstreeRepo *self,
|
||||
dirmeta, out_csum, cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_get_object_path:
|
||||
* @self:
|
||||
* @checksum: SHA256 checksum string
|
||||
* @type: Object type
|
||||
*
|
||||
* This function directly retrieves the path of loose objects; it is a
|
||||
* low level API as one cannot assume that all objects are loose. Use
|
||||
* higher level API such as ostree_repo_load_file() if possible.
|
||||
*
|
||||
* Returns: (transfer full): A new file containing the direct path to a loose object
|
||||
*/
|
||||
GFile *
|
||||
ostree_repo_get_object_path (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
OstreeObjectType type)
|
||||
_ostree_repo_get_object_path (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
OstreeObjectType type)
|
||||
{
|
||||
char *relpath;
|
||||
GFile *ret;
|
||||
@@ -2198,7 +2186,7 @@ repo_find_object (OstreeRepo *self,
|
||||
gs_unref_object GFile *object_path = NULL;
|
||||
gs_unref_object GFile *ret_stored_path = NULL;
|
||||
|
||||
object_path = ostree_repo_get_object_path (self, checksum, objtype);
|
||||
object_path = _ostree_repo_get_object_path (self, checksum, objtype);
|
||||
|
||||
if (lstat (gs_file_get_path_cached (object_path), &stbuf) == 0)
|
||||
{
|
||||
@@ -2249,6 +2237,63 @@ ostree_repo_has_object (OstreeRepo *self,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_delete_object:
|
||||
* @self:
|
||||
* @objtype: Object type
|
||||
* @sha256: Checksum
|
||||
* @cancellable:
|
||||
* @error:
|
||||
*
|
||||
* Remove the object of type @objtype with checksum @sha256
|
||||
* from the repository. An error of type %G_IO_ERROR_NOT_FOUND
|
||||
* is thrown if the object does not exist.
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_delete_object (OstreeRepo *self,
|
||||
OstreeObjectType objtype,
|
||||
const char *sha256,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gs_unref_object GFile *objpath = _ostree_repo_get_object_path (self, sha256, objtype);
|
||||
return gs_file_unlink (objpath, cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_query_object_storage_size:
|
||||
* @self:
|
||||
* @objtype: Object type
|
||||
* @sha256: Checksum
|
||||
* @out_size: (out): Size in bytes object occupies physically
|
||||
* @cancellable:
|
||||
* @error:
|
||||
*
|
||||
* Return the size in bytes of object with checksum @sha256, after any
|
||||
* compression has been applied.
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_query_object_storage_size (OstreeRepo *self,
|
||||
OstreeObjectType objtype,
|
||||
const char *sha256,
|
||||
gsize *out_size,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *objpath = _ostree_repo_get_object_path (self, sha256, objtype);
|
||||
gs_unref_object GFileInfo *finfo = g_file_query_info (objpath, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
if (!finfo)
|
||||
goto out;
|
||||
|
||||
*out_size = g_file_info_get_size (finfo);
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_repo_load_variant_c (OstreeRepo *self,
|
||||
OstreeObjectType objtype,
|
||||
|
||||
@@ -65,10 +65,6 @@ gboolean ostree_repo_write_config (OstreeRepo *self,
|
||||
GKeyFile *new_config,
|
||||
GError **error);
|
||||
|
||||
GFile * ostree_repo_get_object_path (OstreeRepo *self,
|
||||
const char *checksum,
|
||||
OstreeObjectType type);
|
||||
|
||||
gboolean ostree_repo_prepare_transaction (OstreeRepo *self,
|
||||
gboolean enable_commit_hardlink_scan,
|
||||
gboolean *out_transaction_resume,
|
||||
@@ -204,6 +200,19 @@ gboolean ostree_repo_load_file (OstreeRepo *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_query_object_storage_size (OstreeRepo *self,
|
||||
OstreeObjectType objtype,
|
||||
const char *sha256,
|
||||
gsize *out_size,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_delete_object (OstreeRepo *self,
|
||||
OstreeObjectType objtype,
|
||||
const char *sha256,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
typedef enum {
|
||||
OSTREE_REPO_COMMIT_FILTER_ALLOW,
|
||||
OSTREE_REPO_COMMIT_FILTER_SKIP
|
||||
|
||||
Reference in new issue
Block a user