Skip to content

Commit

Permalink
Do not run check or compact commands if --dry-run is requested
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Oct 29, 2023
1 parent 9a17f82 commit b066e98
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions emborg/emborg.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@
from .utilities import getfullhostname, gethostname, getusername

# Globals {{{1
borg_commands_with_dryrun = "create extract delete prune upgrade recreate".split()
borg_commands_with_dryrun = "create delete extract prune upgrade recreate".split()
dangerous_borg_commands_without_dryrun = "check compact"
# The commands that modify the repository and do not support --dry-run.
# When specifying --dry-run user expects to be safe. These commands may not
# be safe. Refuse to run if user requests --dry-run on these commands.
set_shlib_prefs(use_inform=True, log_cmd=True, encoding=DEFAULT_ENCODING)

# Utilities {{{1
Expand Down Expand Up @@ -528,8 +532,11 @@ def borg_options(self, cmd, borg_opts, emborg_opts, strip_prefix):
emborg_opts.append("verbose")
if "verbose" in emborg_opts:
borg_opts.append("--verbose")
if "dry-run" in emborg_opts and cmd in borg_commands_with_dryrun:
borg_opts.append("--dry-run")
if "dry-run" in emborg_opts:
if cmd in borg_commands_with_dryrun:
borg_opts.append("--dry-run")
elif cmd in dangerous_borg_commands_without_dryrun:
raise Error(f"--dry-run is not available with {cmd} command.")

if cmd == "create":
if "verbose" in emborg_opts and "--list" not in borg_opts:
Expand Down

0 comments on commit b066e98

Please sign in to comment.