core: Change compose to operate purely in-memory
This is *significantly* faster than checking out each branch into the real filesystem, then importing it again.
This commit is contained in:
1 parent
add55849ab
commit
e9fd921afe
6 files changed
+128
-135
No files matched your search
@@ -95,6 +95,31 @@ ostree_mutable_tree_set_contents_checksum (OstreeMutableTree *self,
|
||||
const char *
|
||||
ostree_mutable_tree_get_contents_checksum (OstreeMutableTree *self)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
if (!self->contents_checksum)
|
||||
return NULL;
|
||||
|
||||
/* Ensure the cache is valid; this implementation is a bit
|
||||
* lame in that we walk the whole tree every time this
|
||||
* getter is called; a better approach would be to invalidate
|
||||
* all of the parents whenever a child is modified.
|
||||
*
|
||||
* However, we only call this function once right now.
|
||||
*/
|
||||
g_hash_table_iter_init (&iter, self->subdirs);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
OstreeMutableTree *subdir = value;
|
||||
if (!ostree_mutable_tree_get_contents_checksum (subdir))
|
||||
{
|
||||
g_free (self->contents_checksum);
|
||||
self->contents_checksum = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return self->contents_checksum;
|
||||
}
|
||||
|
||||
@@ -122,6 +147,7 @@ ostree_mutable_tree_replace_file (OstreeMutableTree *self,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ostree_mutable_tree_set_contents_checksum (self, NULL);
|
||||
g_hash_table_replace (self->files,
|
||||
g_strdup (name),
|
||||
g_strdup (checksum));
|
||||
@@ -153,6 +179,7 @@ ostree_mutable_tree_ensure_dir (OstreeMutableTree *self,
|
||||
if (!ret_dir)
|
||||
{
|
||||
ret_dir = ostree_mutable_tree_new ();
|
||||
ostree_mutable_tree_set_contents_checksum (self, NULL);
|
||||
g_hash_table_insert (self->subdirs, g_strdup (name), g_object_ref (ret_dir));
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,12 @@ ostree_repo_file_ensure_resolved (OstreeRepoFile *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const char *
|
||||
ostree_repo_file_get_commit (OstreeRepoFile *self)
|
||||
{
|
||||
return ostree_repo_file_get_root (self)->commit;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_repo_file_get_xattrs (OstreeRepoFile *self,
|
||||
GVariant **out_xattrs,
|
||||
|
||||
@@ -75,6 +75,8 @@ gboolean ostree_repo_file_is_tree (OstreeRepoFile *self);
|
||||
|
||||
const char * ostree_repo_file_get_checksum (OstreeRepoFile *self);
|
||||
|
||||
const char * ostree_repo_file_get_commit (OstreeRepoFile *self);
|
||||
|
||||
GFile *ostree_repo_file_nontree_get_local (OstreeRepoFile *self);
|
||||
|
||||
int ostree_repo_file_tree_find_child (OstreeRepoFile *self,
|
||||
|
||||
@@ -1380,6 +1380,7 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
|
||||
GChecksum *child_file_checksum = NULL;
|
||||
GVariant *xattrs = NULL;
|
||||
GInputStream *file_input = NULL;
|
||||
gboolean repo_dir_was_empty = FALSE;
|
||||
|
||||
/* We can only reuse checksums directly if there's no modifier */
|
||||
if (OSTREE_IS_REPO_FILE (dir) && modifier == NULL)
|
||||
@@ -1388,7 +1389,9 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
|
||||
if (repo_dir)
|
||||
{
|
||||
ostree_mutable_tree_set_metadata_checksum (mtree, ostree_repo_file_get_checksum (repo_dir));
|
||||
ostree_mutable_tree_set_contents_checksum (mtree, ostree_repo_file_tree_get_content_checksum (repo_dir));
|
||||
repo_dir_was_empty =
|
||||
g_hash_table_size (ostree_mutable_tree_get_files (mtree)) == 0
|
||||
&& g_hash_table_size (ostree_mutable_tree_get_subdirs (mtree)) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1484,6 +1487,9 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (repo_dir && repo_dir_was_empty)
|
||||
ostree_mutable_tree_set_contents_checksum (mtree, ostree_repo_file_tree_get_content_checksum (repo_dir));
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
g_clear_object (&dir_enum);
|
||||
@@ -1593,10 +1599,12 @@ ostree_repo_stage_mtree (OstreeRepo *self,
|
||||
GVariant *serialized_tree = NULL;
|
||||
GHashTableIter hash_iter;
|
||||
gpointer key, value;
|
||||
const char *existing_checksum;
|
||||
|
||||
if (ostree_mutable_tree_get_contents_checksum (mtree))
|
||||
existing_checksum = ostree_mutable_tree_get_contents_checksum (mtree);
|
||||
if (existing_checksum)
|
||||
{
|
||||
ret_contents_checksum = g_strdup (ostree_mutable_tree_get_contents_checksum (mtree));
|
||||
ret_contents_checksum = g_strdup (existing_checksum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user