Add new settings db_path
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user