Allow creating and pulling static deltas starting from "empty"
You create these with something like: ostree static-delta generate --empty --to=master These will be automatically used during pull if no previous revision exists in the target repo. These work very much like the normal static deltas except they are named just by the "to" revision. I.e: deltas/94/f7d2dc23759dd21f9bd01e6705a8fdf98f90cad3e0109ba3f6c091c1a3774d for a from-scratch to 94f7d2dc23759dd21f9bd01e6705a8fdf98f90cad3e0109ba3f6c091c1a3774d delta. https://bugzilla.gnome.org/show_bug.cgi?id=721799
This commit is contained in:
1 parent
82ed6c43ed
commit
5b721a5b08
7 files changed
+78
-30
No files matched your search
@@ -1348,11 +1348,22 @@ get_delta_path (const char *from,
|
||||
const char *target)
|
||||
{
|
||||
char prefix[3];
|
||||
prefix[0] = from[0];
|
||||
prefix[1] = from[1];
|
||||
prefix[2] = '\0';
|
||||
from += 2;
|
||||
return g_strconcat ("deltas/", prefix, "/", from, "-", to, "/", target, NULL);
|
||||
if (from == NULL)
|
||||
{
|
||||
prefix[0] = to[0];
|
||||
prefix[1] = to[1];
|
||||
prefix[2] = '\0';
|
||||
to += 2;
|
||||
return g_strconcat ("deltas/", prefix, "/", to, "/", target, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix[0] = from[0];
|
||||
prefix[1] = from[1];
|
||||
prefix[2] = '\0';
|
||||
from += 2;
|
||||
return g_strconcat ("deltas/", prefix, "/", from, "-", to, "/", target, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
@@ -204,7 +204,7 @@ diff_add_dir_recurse (GFile *d,
|
||||
/**
|
||||
* ostree_diff_dirs:
|
||||
* @flags: Flags
|
||||
* @a: First directory path
|
||||
* @a: First directory path, or %NULL
|
||||
* @b: First directory path
|
||||
* @modified: (element-type OstreeDiffItem): Modified files
|
||||
* @removed: (element-type Gio.File): Removed files
|
||||
@@ -231,6 +231,15 @@ ostree_diff_dirs (OstreeDiffFlags flags,
|
||||
gs_unref_object GFileInfo *child_a_info = NULL;
|
||||
gs_unref_object GFileInfo *child_b_info = NULL;
|
||||
|
||||
if (a == NULL)
|
||||
{
|
||||
if (!diff_add_dir_recurse (b, added, cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
child_a_info = g_file_query_info (a, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
|
||||
@@ -1446,7 +1446,7 @@ process_one_static_delta (OtPullData *pull_data,
|
||||
if (have_all)
|
||||
{
|
||||
g_debug ("Have all objects from static delta %s-%s part %u",
|
||||
from_revision, to_revision,
|
||||
from_revision ? from_revision : "empty", to_revision,
|
||||
i);
|
||||
continue;
|
||||
}
|
||||
@@ -1912,7 +1912,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
&from_revision, error))
|
||||
goto out;
|
||||
|
||||
if (from_revision && g_strcmp0 (from_revision, to_revision) != 0)
|
||||
if (from_revision == NULL || g_strcmp0 (from_revision, to_revision) != 0)
|
||||
{
|
||||
if (!request_static_delta_superblock_sync (pull_data, from_revision, to_revision,
|
||||
&delta_superblock, cancellable, error))
|
||||
@@ -1921,14 +1921,14 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
|
||||
if (!delta_superblock)
|
||||
{
|
||||
g_debug ("no delta superblock for %s-%s", from_revision, to_revision);
|
||||
g_debug ("no delta superblock for %s-%s", from_revision ? from_revision : "empty", to_revision);
|
||||
if (!scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
0, pull_data->cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("processing delta superblock for %s-%s", from_revision, to_revision);
|
||||
g_debug ("processing delta superblock for %s-%s", from_revision ? from_revision : "empty", to_revision);
|
||||
if (!process_one_static_delta (pull_data, from_revision, to_revision,
|
||||
delta_superblock,
|
||||
cancellable, error))
|
||||
|
||||
@@ -203,9 +203,12 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||
gs_unref_hashtable GHashTable *modified_content_objects = NULL;
|
||||
gs_unref_hashtable GHashTable *content_object_to_size = NULL;
|
||||
|
||||
if (!ostree_repo_read_commit (repo, from, &root_from, NULL,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
if (from != NULL)
|
||||
{
|
||||
if (!ostree_repo_read_commit (repo, from, &root_from, NULL,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
if (!ostree_repo_read_commit (repo, to, &root_to, NULL,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
@@ -231,9 +234,12 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||
g_hash_table_add (modified_content_objects, objname);
|
||||
}
|
||||
|
||||
if (!ostree_repo_traverse_commit (repo, from, 0, &from_reachable_objects,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
if (from)
|
||||
{
|
||||
if (!ostree_repo_traverse_commit (repo, from, 0, &from_reachable_objects,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ostree_repo_traverse_commit (repo, to, 0, &to_reachable_objects,
|
||||
cancellable, error))
|
||||
@@ -249,7 +255,7 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||
const char *checksum;
|
||||
OstreeObjectType objtype;
|
||||
|
||||
if (g_hash_table_contains (from_reachable_objects, serialized_key))
|
||||
if (from_reachable_objects && g_hash_table_contains (from_reachable_objects, serialized_key))
|
||||
continue;
|
||||
|
||||
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
|
||||
@@ -412,17 +418,17 @@ get_fallback_headers (OstreeRepo *self,
|
||||
* ostree_repo_static_delta_generate:
|
||||
* @self: Repo
|
||||
* @opt: High level optimization choice
|
||||
* @from: ASCII SHA256 checksum of origin
|
||||
* @from: ASCII SHA256 checksum of origin, or %NULL
|
||||
* @to: ASCII SHA256 checksum of target
|
||||
* @metadata: (allow-none): Optional metadata
|
||||
* @params: (allow-none): Parameters, see below
|
||||
* @cancellable: Cancellable
|
||||
* @error: Error
|
||||
*
|
||||
* Generate a lookaside "static delta" from @from which can generate
|
||||
* the objects in @to. This delta is an optimization over fetching
|
||||
* individual objects, and can be conveniently stored and applied
|
||||
* offline.
|
||||
* Generate a lookaside "static delta" from @from (%NULL means
|
||||
* from-empty) which can generate the objects in @to. This delta is
|
||||
* an optimization over fetching individual objects, and can be
|
||||
* conveniently stored and applied offline.
|
||||
*
|
||||
* The @params argument should be an a{sv}. The following attributes
|
||||
* are known:
|
||||
@@ -590,9 +596,10 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
{
|
||||
GDateTime *now = g_date_time_new_now_utc ();
|
||||
/* floating */ GVariant *from_csum_v =
|
||||
ostree_checksum_to_bytes_v (from);
|
||||
from ? ostree_checksum_to_bytes_v (from) : ot_gvariant_new_bytearray ((guchar *)"", 0);
|
||||
/* floating */ GVariant *to_csum_v =
|
||||
ostree_checksum_to_bytes_v (to);
|
||||
|
||||
delta_descriptor = g_variant_new ("(@(a(ss)a(say))t@ay@ay@" OSTREE_COMMIT_GVARIANT_STRING "ay"
|
||||
"a" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT
|
||||
"@a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")",
|
||||
|
||||
@@ -3069,7 +3069,7 @@ out:
|
||||
/**
|
||||
* ostree_repo_sign_delta:
|
||||
* @self: Self
|
||||
* @from_commit: SHA256 of starting commit to sign
|
||||
* @from_commit: SHA256 of starting commit to sign, or %NULL
|
||||
* @to_commit: SHA256 of target commit to sign
|
||||
* @key_id: Use this GPG key id
|
||||
* @homedir: (allow-none): GPG home directory, or %NULL
|
||||
|
||||
Reference in new issue
Block a user