diff --git a/changelog.d/2921.enhance.rst b/changelog.d/2921.enhance.rst new file mode 100644 index 000000000..7d372cf29 --- /dev/null +++ b/changelog.d/2921.enhance.rst @@ -0,0 +1 @@ +JSON config files are now stored without indentation, this is to reduce file size and increase performance of write operations. diff --git a/redbot/core/drivers/red_json.py b/redbot/core/drivers/red_json.py index f598f6cf4..54e73e715 100644 --- a/redbot/core/drivers/red_json.py +++ b/redbot/core/drivers/red_json.py @@ -95,7 +95,7 @@ class JSON(BaseDriver): except FileNotFoundError: self.data = {} with self.data_path.open("w", encoding="utf-8") as fs: - json.dump(self.data, fs, indent=4) + json.dump(self.data, fs) def migrate_identifier(self, raw_identifier: int): if self.unique_cog_identifier in self.data: @@ -206,7 +206,7 @@ def _save_json(path: Path, data: Dict[str, Any]) -> None: tmp_file = "{}-{}.tmp".format(filename, uuid4().fields[0]) tmp_path = path.parent / tmp_file with tmp_path.open(encoding="utf-8", mode="w") as fs: - json.dump(data, fs, indent=4) + json.dump(data, fs) fs.flush() # This does get closed on context exit, ... os.fsync(fs.fileno()) # but that needs to happen prior to this line