cli: fix handling of erroneous connections in "delete"

If we can't find a connection for any reason other than that it doesn't
exist, we should error out immediately and consistently, regardless of
whether we already encountered a non-existent connection.
This commit is contained in:
Lubomir Rintel
2022-03-17 14:11:05 +01:00
parent e39e5d9372
commit c7ab380a5c

View File

@@ -9132,8 +9132,11 @@ do_connection_delete(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
nmc->return_value = error->code;
g_clear_error(&error);
if (nmc->return_value != NMC_RESULT_ERROR_NOT_FOUND)
if (nmc->return_value != NMC_RESULT_ERROR_NOT_FOUND) {
g_string_free(invalid_cons, TRUE);
invalid_cons = NULL;
goto finish;
}
if (!invalid_cons)
invalid_cons = g_string_new(NULL);
@@ -9186,7 +9189,6 @@ finish:
g_string_printf(nmc->return_text,
_("Error: cannot delete unknown connection(s): %s."),
invalid_cons->str);
nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
}
}