mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
Stop saving JSON files with indents (#2921)
Stop saving json files with 4 indents, this will significantly reduce file size and improve `.set()` performance for config saves when using the JSON driver. Signed-off-by: Draper <guyreis96@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user