]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: kresctl: config cmd: write to file only with 200 response status
authorAleš Mrázek <ales.mrazek@nic.cz>
Fri, 30 Sep 2022 13:12:03 +0000 (15:12 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 10 Jan 2023 18:57:14 +0000 (19:57 +0100)
manager/knot_resolver_manager/cli/cmd/config.py

index 415db136423718bab1b59a37ebada2d97af66c07..e09a4b8cd37fa2b24b62fa36c73311df1e038cc4 100644 (file)
@@ -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))