From f176d3eba3a69696c3fff8f4aded08019287d77e Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 9 Aug 2018 14:11:35 +0200 Subject: [PATCH] Add --disable-fsync to build-export and build-commit-from This mirrors ostree commit --disable-fsync and is useful in some cases. For instance, we'd like to use it when building the temporary import repositories in flathub. Closes: #1951 Approved by: alexlarsson --- app/flatpak-builtins-build-commit-from.c | 5 +++++ app/flatpak-builtins-build-export.c | 5 +++++ doc/flatpak-build-commit-from.xml | 9 +++++++++ doc/flatpak-build-export.xml | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/app/flatpak-builtins-build-commit-from.c b/app/flatpak-builtins-build-commit-from.c index fd3e90eb..13ee4cfd 100644 --- a/app/flatpak-builtins-build-commit-from.c +++ b/app/flatpak-builtins-build-commit-from.c @@ -40,6 +40,7 @@ static char *opt_body; static gboolean opt_update_appstream; static gboolean opt_no_update_summary; static gboolean opt_untrusted; +static gboolean opt_disable_fsync; static gboolean opt_force; static char **opt_gpg_key_ids; static char *opt_gpg_homedir; @@ -59,6 +60,7 @@ static GOptionEntry options[] = { { "gpg-homedir", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_homedir, N_("GPG Homedir to use when looking for keyrings"), N_("HOMEDIR") }, { "end-of-life", 0, 0, G_OPTION_ARG_STRING, &opt_endoflife, N_("Mark build as end-of-life"), N_("REASON") }, { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, N_("Override the timestamp of the commit (NOW for current time)"), N_("TIMESTAMP") }, + { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL }, { NULL } }; @@ -271,6 +273,9 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella if (!ostree_repo_open (dst_repo, cancellable, error)) return FALSE; + if (opt_disable_fsync) + ostree_repo_set_disable_fsync (dst_repo, TRUE); + if (opt_src_repo) { src_repofile = g_file_new_for_commandline_arg (opt_src_repo); diff --git a/app/flatpak-builtins-build-export.c b/app/flatpak-builtins-build-export.c index 7acca3fd..f3cd57cf 100644 --- a/app/flatpak-builtins-build-export.c +++ b/app/flatpak-builtins-build-export.c @@ -39,6 +39,7 @@ static char *opt_arch; static gboolean opt_runtime; static gboolean opt_update_appstream; static gboolean opt_no_update_summary; +static gboolean opt_disable_fsync; static char **opt_gpg_key_ids; static char **opt_exclude; static char **opt_include; @@ -65,6 +66,7 @@ static GOptionEntry options[] = { { "end-of-life", 0, 0, G_OPTION_ARG_STRING, &opt_endoflife, N_("Mark build as end-of-life"), N_("REASON") }, { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, N_("Override the timestamp of the commit"), N_("TIMESTAMP") }, { "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id, N_("Collection ID"), "COLLECTION-ID" }, + { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL }, { NULL } }; @@ -808,6 +810,9 @@ flatpak_builtin_build_export (int argc, char **argv, GCancellable *cancellable, goto out; } + if (opt_disable_fsync) + ostree_repo_set_disable_fsync (repo, TRUE); + /* Get the canonical collection ID which we’ll use for the commit. This might * be %NULL if the existing repo doesn’t have one and none was specified on * the command line. */ diff --git a/doc/flatpak-build-commit-from.xml b/doc/flatpak-build-commit-from.xml index 9684422e..721a42d3 100644 --- a/doc/flatpak-build-commit-from.xml +++ b/doc/flatpak-build-commit-from.xml @@ -157,6 +157,15 @@ + + + + + Don't fsync when writing to the repository. This can result in data loss in exceptional situations, but can improve performance when + working with temporary or test repositories. + + + diff --git a/doc/flatpak-build-export.xml b/doc/flatpak-build-export.xml index 0c4b3f6f..1ee766da 100644 --- a/doc/flatpak-build-export.xml +++ b/doc/flatpak-build-export.xml @@ -177,6 +177,15 @@ + + + + + Don't fsync when writing to the repository. This can result in data loss in exceptional situations, but can improve performance when + working with temporary or test repositories. + + +