Skip to content

Commit

Permalink
fix: fix encoding for compressing and decompressing json files
Browse files Browse the repository at this point in the history
  • Loading branch information
daxartio committed Nov 24, 2024
1 parent 082581e commit ab70d6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sportorg/modules/backup/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _backup(self, file_name: str, func, mode: str = "r") -> None:
except gzip.BadGzipFile:
use_gzip = False

def_encoding = "utf-8" if use_utf8 else None
def_encoding = "utf-8" if use_utf8 and not use_gzip else None
if use_gzip:
mode = f"{mode}+b"

Expand All @@ -42,7 +42,7 @@ def _backup(self, file_name: str, func, mode: str = "r") -> None:
except UnicodeDecodeError:
f.close()

alt_encoding: Optional[str] = "utf-8" if use_utf8 else None
alt_encoding: Optional[str] = None if use_utf8 or use_gzip else "utf-8"

with open(file_name, mode, encoding=alt_encoding) as f:
func(f, compress=use_gzip)
Expand Down

0 comments on commit ab70d6c

Please sign in to comment.