Merge pull request #24354 from akhilnarang/check-for-gpg-install

fix: add a check for `gpg` existing
This commit is contained in:
mergify[bot] 2024-01-15 12:44:02 +00:00 committed by GitHub
commit 7c526bc7cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ import contextlib
# imports - standard imports
import gzip
import os
import sys
from calendar import timegm
from datetime import datetime
from glob import glob
@ -225,6 +226,9 @@ class BackupGenerator:
"""
Encrypt all the backups created using gpg.
"""
if which("gpg") is None:
click.secho("Please install `gpg` and ensure its available in your PATH", fg="red")
sys.exit(1)
paths = (self.backup_path_db, self.backup_path_files, self.backup_path_private_files)
for path in paths:
if os.path.exists(path):
@ -640,6 +644,9 @@ def get_or_generate_backup_encryption_key():
@contextlib.contextmanager
def decrypt_backup(file_path: str, passphrase: str):
if which("gpg") is None:
click.secho("Please install `gpg` and ensure its available in your PATH", fg="red")
sys.exit(1)
if not os.path.exists(file_path):
print("Invalid path: ", file_path)
return