From b5bc5cbf39e27d40e82f79cdcd089ccd577a469b Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 6 Aug 2024 15:07:24 +0800 Subject: [PATCH] Add new settings db_path --- example.yaml | 1 + game_backuper/config.py | 5 +++++ game_backuper/db.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/example.yaml b/example.yaml index 6810ea4..a6e8142 100644 --- a/example.yaml +++ b/example.yaml @@ -8,6 +8,7 @@ compress_method: "bzip2" # Optional. Default value: null. Supported value: "bzi compress_level: 6 encrypt_db: false # Optional. Default value: false. Encrypt the database. Warning: The default python sqlite library don't support encrypt, it just ignore encrypt phases. db_password: "Password" # Specify the password of the encryped database. +db_path: /path/to/db/path # Optional. Default value: $dest/data.db. The path to the database. encrypt_files: false # Optional. Default value: false. Encrypt backup files. The key information will stored in database. protect_filename: false # Optional. Default value: false. Use id in database as file name. Only works when encrypt_files is true. unpin_file: false # Optional. Default value: false. Notifiy sync provider to dehydrate file data. diff --git a/game_backuper/config.py b/game_backuper/config.py index 0d63223..7d40796 100644 --- a/game_backuper/config.py +++ b/game_backuper/config.py @@ -519,6 +519,7 @@ class Config(BasicOption, NFBasicOption): dest = '' encrypt_db = False db_password = None + db_path = None progs = [] progs_name = [] @@ -542,6 +543,10 @@ class Config(BasicOption, NFBasicOption): if not isinstance(t['db_password'], str): raise ValueError('db_password should be a string.') self.db_password = t['db_password'] + if 'db_path' in t: + if not isinstance(t['db_path'], str): + raise ValueError('db_path should be a string.') + self.db_path = t['db_path'] if 'programs' not in t: raise ValueError("No programs found.") self.parse_all(t) diff --git a/game_backuper/db.py b/game_backuper/db.py index 767f735..1542594 100644 --- a/game_backuper/db.py +++ b/game_backuper/db.py @@ -85,7 +85,7 @@ class Db: def __init__(self, config: Config, opts: Opts): self._cfg = config self._opt = opts - fn = join(config.dest, "data.db") + fn = config.db_path if config.db_path else join(config.dest, "data.db") hydrate_file_if_needed(fn) self.db = connect(fn, check_same_thread=False) if config.encrypt_db: