app: Fix inefficiency in pin and mask commands

There's no point reading data from disk on a code path that doesn't do
anything with it.
This commit is contained in:
Phaedrus Leeds
2022-07-01 15:01:48 -07:00
committed by Patrick
parent f4b038c8b1
commit bf93e004e9
2 changed files with 8 additions and 6 deletions

View File

@@ -49,7 +49,6 @@ flatpak_builtin_mask (int argc, char **argv, GCancellable *cancellable, GError *
g_autoptr(GOptionContext) context = NULL;
g_autoptr(GPtrArray) dirs = NULL;
FlatpakDir *dir;
g_autoptr(GPtrArray) patterns = NULL;
int i;
context = g_option_context_new (_("[PATTERN…] - disable updates and automatic installation matching patterns"));
@@ -62,10 +61,12 @@ flatpak_builtin_mask (int argc, char **argv, GCancellable *cancellable, GError *
dir = g_ptr_array_index (dirs, 0);
patterns = flatpak_dir_get_config_patterns (dir, "masked");
if (argc == 1)
{
g_autoptr(GPtrArray) patterns = NULL;
patterns = flatpak_dir_get_config_patterns (dir, "masked");
if (patterns->len == 0)
{
if (flatpak_fancy_output ())

View File

@@ -51,7 +51,6 @@ flatpak_builtin_pin (int argc, char **argv, GCancellable *cancellable, GError **
g_autoptr(GOptionContext) context = NULL;
g_autoptr(GPtrArray) dirs = NULL;
FlatpakDir *dir;
g_autoptr(GPtrArray) patterns = NULL;
int i;
context = g_option_context_new (_("[PATTERN…] - disable automatic removal of runtimes matching patterns"));
@@ -64,10 +63,12 @@ flatpak_builtin_pin (int argc, char **argv, GCancellable *cancellable, GError **
dir = g_ptr_array_index (dirs, 0);
patterns = flatpak_dir_get_config_patterns (dir, "pinned");
if (argc == 1)
{
g_autoptr(GPtrArray) patterns = NULL;
patterns = flatpak_dir_get_config_patterns (dir, "pinned");
if (patterns->len == 0)
{
if (flatpak_fancy_output ())