From: Aleš Mrázek Date: Fri, 30 Sep 2022 13:12:03 +0000 (+0200) Subject: manager: kresctl: config cmd: write to file only with 200 response status X-Git-Tag: v6.0.0a1~12^2~25 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=13e9755af156feed2e4693933ee7a7a81b8397e7;p=thirdparty%2Fknot-resolver.git manager: kresctl: config cmd: write to file only with 200 response status --- diff --git a/manager/knot_resolver_manager/cli/cmd/config.py b/manager/knot_resolver_manager/cli/cmd/config.py index 415db1364..e09a4b8cd 100644 --- a/manager/knot_resolver_manager/cli/cmd/config.py +++ b/manager/knot_resolver_manager/cli/cmd/config.py @@ -134,9 +134,9 @@ class ConfigCommand(Command): response = request(method, url, reformat(new_config, Formats.JSON) if new_config else None) print(f"status: {response.status}") - if self.operation == Operations.GET and self.value_or_file: + if self.operation == Operations.GET and self.value_or_file and response.status == 200: with open(self.value_or_file, "w") as f: f.write(reformat(response.body, self.format)) - print(f"response body saved to: {self.value_or_file}") + print(f"saved to: {self.value_or_file}") else: print(reformat(response.body, self.format))