chore: handle restoring gzipped backups

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-02-13 16:04:02 +05:30
parent 368d7ae298
commit 6e31745290
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -54,7 +54,14 @@ def copy_db(db_file=None, verbose=False):
destination_db_folder.mkdir()
destination_db_path = destination_db_folder / f"{db_name}.db"
shutil.copy(db_path, destination_db_path)
if db_path.suffix == ".gz":
import gzip
with gzip.open(db_file, "rb") as input, open(destination_db_path, "wb") as output:
shutil.copyfileobj(input, output)
else:
shutil.copy(db_path, destination_db_path)
if verbose:
print("Imported from database {}".format(db_path))