Skip to content

Commit

Permalink
allow borg-space to run without exclusivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Mar 17, 2022
1 parent 0c9089a commit 6ae48ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 0 additions & 6 deletions doc/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,6 @@ unmount a remote repository, if such a thing is needed.
May be specified as a list of strings or as a multi-line string with one command
per line (lines that begin with ``#`` are ignored).

Of all the *run_before_* and *run_after_* settings, only *run_after_borg* may
contain *Emborg* commands. The reason being is that *Emborg* sets a lock file
while running and that lock file is not removed until just before the
*run_after_borg* commands are run. Thus, if you wish to automatically run
`borg-space <https://github.com/KenKundert/borg-space>`_ to record the size of
your backups over time, you should include the command in *run_after_borg*.

.. _show_progress:

Expand Down
2 changes: 1 addition & 1 deletion emborg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():

queue = ConfigQueue(cmd)
while queue:
with Settings(config, emborg_opts, queue) as settings:
with Settings(config, emborg_opts, queue=queue) as settings:
try:
exit_status = cmd.execute(
cmd_name, args, settings, emborg_opts
Expand Down
13 changes: 8 additions & 5 deletions emborg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
username = getusername()


# borg_options_arg_count {{{1
# borg_options_arg_count {{{2
borg_options_arg_count = {
"borg": 1,
"--exclude": 1,
Expand All @@ -108,7 +108,7 @@
borg_options_arg_count[convert_name_to_option(name)] = 1


# ConfigQueue {{{2
# ConfigQueue {{{1
class ConfigQueue:
def __init__(self, command=None):
self.uninitialized = True
Expand Down Expand Up @@ -200,7 +200,7 @@ def __bool__(self):
# Settings class {{{1
class Settings:
# Constructor {{{2
def __init__(self, config=None, emborg_opts=(), _queue=None):
def __init__(self, config=None, emborg_opts=(), **kwargs):
self.settings = dict()
self.do_not_expand = ()
self.emborg_opts = emborg_opts
Expand All @@ -210,7 +210,7 @@ def __init__(self, config=None, emborg_opts=(), _queue=None):
# logfile for this config
get_informer().set_logfile(LoggingCache())
self.config_dir = to_path(CONFIG_DIR)
self.read_config(name=config, queue=_queue)
self.read_config(name=config, **kwargs)
self.check()
set_shlib_prefs(encoding=self.encoding if self.encoding else DEFAULT_ENCODING)
self.hooks = Hooks(self)
Expand All @@ -227,7 +227,7 @@ def __init__(self, config=None, emborg_opts=(), _queue=None):
warn(f'unknown colorscheme: {self.colorscheme}.')

# read_config() {{{2
def read_config(self, name=None, path=None, queue=None):
def read_config(self, name=None, path=None, **kwargs):
"""Recursively read configuration files.
name (str):
Expand Down Expand Up @@ -282,6 +282,7 @@ def read_config(self, name=None, path=None, queue=None):
settings = path.run()

# initialize the config queue
queue = kwargs.get('queue')
if not queue:
# this is a request through the API
queue = ConfigQueue()
Expand All @@ -291,6 +292,8 @@ def read_config(self, name=None, path=None, queue=None):
self.configs = queue.configs
self.log_command = queue.log_command
self.requires_exclusivity = queue.requires_exclusivity
if 'exclusive' in kwargs:
self.requires_exclusivity = kwargs['exclusive']

# save config name
settings["config_name"] = config
Expand Down

0 comments on commit 6ae48ee

Please sign in to comment.