From 3eaec588d79fc2d53c4fc865bc3b97d97be5c179 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 3 Apr 2020 12:56:59 +0200 Subject: [PATCH] Don't always create commitpartial files in child repos We used to always create a commitpartial file in child repo, because ostree doesn't follow parent repos when loading commitpartial state, and when the commit was in the parent repo it would find the commit but no commitpartial and assume the commit was complete and do nothing. However, having a commitpartial file seems to break delta downloads in ostree, as per: https://github.com/ostreedev/ostree/issues/2053 causing us to download too much data when using deltas. So, we now only create a commitpartial if there is one in the parent repo. This still means we will get the ostree problems in case there is one, but in the much more common case we avoid the issue. In order to "fix" the uncommon case we also (separately) cap the reported progress at 100%. (We should probably also fix the upstream ostree issue too.) --- common/flatpak-dir.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index d7589eb0..f8c126ea 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -8160,16 +8160,21 @@ flatpak_dir_create_child_repo (FlatpakDir *self, verify + fsync when importing to stable storage */ ostree_repo_set_disable_fsync (repo, TRUE); - /* Create a commitpartial in the child repo to ensure we download everything, because - any commitpartial state in the parent will not be inherited */ + /* Create a commitpartial in the child repo if needed to ensure we download everything, because + any commitpartial state in the parent will not otherwise be inherited */ if (optional_commit) { g_autofree char *commitpartial_basename = g_strconcat (optional_commit, ".commitpartial", NULL); - g_autoptr(GFile) commitpartial = - flatpak_build_file (ostree_repo_get_path (repo), + g_autoptr(GFile) orig_commitpartial = + flatpak_build_file (ostree_repo_get_path (self->repo), "state", commitpartial_basename, NULL); - - g_file_replace_contents (commitpartial, "", 0, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, NULL); + if (g_file_query_exists (orig_commitpartial, NULL)) + { + g_autoptr(GFile) commitpartial = + flatpak_build_file (ostree_repo_get_path (repo), + "state", commitpartial_basename, NULL); + g_file_replace_contents (commitpartial, "", 0, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, NULL); + } } return g_steal_pointer (&repo); }