core: Don't look in packs if we found loose object
Unless the caller wants us to; which at present none do, but let's be forward looking and add an option.
This commit is contained in:
parent
6fbe15fc05
commit
4fa14eb712
|
|
@ -44,6 +44,7 @@ static gboolean
|
||||||
repo_find_object (OstreeRepo *self,
|
repo_find_object (OstreeRepo *self,
|
||||||
OstreeObjectType objtype,
|
OstreeObjectType objtype,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
|
gboolean lookup_all,
|
||||||
GFile **out_stored_path,
|
GFile **out_stored_path,
|
||||||
char **out_pack_checksum,
|
char **out_pack_checksum,
|
||||||
guint64 *out_pack_offset,
|
guint64 *out_pack_offset,
|
||||||
|
|
@ -1110,14 +1111,14 @@ stage_object (OstreeRepo *self,
|
||||||
{
|
{
|
||||||
if (!(flags & OSTREE_REPO_STAGE_FLAGS_STORE_IF_PACKED))
|
if (!(flags & OSTREE_REPO_STAGE_FLAGS_STORE_IF_PACKED))
|
||||||
{
|
{
|
||||||
if (!repo_find_object (self, objtype, expected_checksum,
|
if (!repo_find_object (self, objtype, expected_checksum, FALSE,
|
||||||
&stored_path, &pack_checksum, &pack_offset,
|
&stored_path, &pack_checksum, &pack_offset,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!repo_find_object (self, objtype, expected_checksum,
|
if (!repo_find_object (self, objtype, expected_checksum, FALSE,
|
||||||
&stored_path, NULL, NULL,
|
&stored_path, NULL, NULL,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -3526,7 +3527,7 @@ ostree_repo_load_file (OstreeRepo *self,
|
||||||
ot_lvariant GVariant *ret_xattrs = NULL;
|
ot_lvariant GVariant *ret_xattrs = NULL;
|
||||||
|
|
||||||
if (!repo_find_object (self, OSTREE_OBJECT_TYPE_FILE,
|
if (!repo_find_object (self, OSTREE_OBJECT_TYPE_FILE,
|
||||||
checksum, &loose_path,
|
checksum, FALSE, &loose_path,
|
||||||
&pack_checksum, &pack_offset,
|
&pack_checksum, &pack_offset,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -3811,6 +3812,7 @@ static gboolean
|
||||||
repo_find_object (OstreeRepo *self,
|
repo_find_object (OstreeRepo *self,
|
||||||
OstreeObjectType objtype,
|
OstreeObjectType objtype,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
|
gboolean lookup_all,
|
||||||
GFile **out_stored_path,
|
GFile **out_stored_path,
|
||||||
char **out_pack_checksum,
|
char **out_pack_checksum,
|
||||||
guint64 *out_pack_offset,
|
guint64 *out_pack_offset,
|
||||||
|
|
@ -3824,24 +3826,29 @@ repo_find_object (OstreeRepo *self,
|
||||||
ot_lobj GFile *ret_stored_path = NULL;
|
ot_lobj GFile *ret_stored_path = NULL;
|
||||||
ot_lfree char *ret_pack_checksum = NULL;
|
ot_lfree char *ret_pack_checksum = NULL;
|
||||||
|
|
||||||
object_path = ostree_repo_get_object_path (self, checksum, objtype);
|
if (out_stored_path)
|
||||||
|
{
|
||||||
|
object_path = ostree_repo_get_object_path (self, checksum, objtype);
|
||||||
|
|
||||||
if (lstat (ot_gfile_get_path_cached (object_path), &stbuf) == 0)
|
if (lstat (ot_gfile_get_path_cached (object_path), &stbuf) == 0)
|
||||||
{
|
{
|
||||||
ret_stored_path = object_path;
|
ret_stored_path = object_path;
|
||||||
object_path = NULL;
|
object_path = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_clear_object (&object_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (!ret_stored_path || lookup_all)
|
||||||
{
|
{
|
||||||
g_clear_object (&object_path);
|
if (out_pack_checksum)
|
||||||
}
|
{
|
||||||
|
if (!find_object_in_packs (self, checksum, objtype,
|
||||||
if (out_pack_checksum)
|
&ret_pack_checksum, &ret_pack_offset,
|
||||||
{
|
cancellable, error))
|
||||||
if (!find_object_in_packs (self, checksum, objtype,
|
goto out;
|
||||||
&ret_pack_checksum, &ret_pack_offset,
|
}
|
||||||
cancellable, error))
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
@ -3867,7 +3874,8 @@ ostree_repo_has_object (OstreeRepo *self,
|
||||||
ot_lobj GFile *loose_path = NULL;
|
ot_lobj GFile *loose_path = NULL;
|
||||||
ot_lfree char *pack_checksum = NULL;
|
ot_lfree char *pack_checksum = NULL;
|
||||||
|
|
||||||
if (!repo_find_object (self, objtype, checksum, &loose_path,
|
if (!repo_find_object (self, objtype, checksum, FALSE,
|
||||||
|
&loose_path,
|
||||||
&pack_checksum, NULL,
|
&pack_checksum, NULL,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -3928,8 +3936,8 @@ ostree_repo_load_variant (OstreeRepo *self,
|
||||||
|
|
||||||
g_return_val_if_fail (OSTREE_OBJECT_TYPE_IS_META (objtype), FALSE);
|
g_return_val_if_fail (OSTREE_OBJECT_TYPE_IS_META (objtype), FALSE);
|
||||||
|
|
||||||
if (!repo_find_object (self, objtype, sha256, &object_path,
|
if (!repo_find_object (self, objtype, sha256, FALSE,
|
||||||
&pack_checksum, &object_offset,
|
&object_path, &pack_checksum, &object_offset,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue