Skip to content

Commit aad5c8a

Browse files
authored
Set auto_delete_log correctly when using --log-dir (#24)
1 parent 062f6d5 commit aad5c8a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

rsync_time_machine.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ def parse_arguments() -> argparse.Namespace: # pragma: no cover
112112
"--rsync-append-flags",
113113
help="Append the rsync flags that are going to be used for backup.",
114114
)
115+
log_dir_default = "$HOME/.rsync-time-backup"
115116
parser.add_argument(
116117
"--log-dir",
117-
default="$HOME/.rsync-time-backup",
118+
default=log_dir_default,
118119
help="Set the log file directory. If this flag is set, generated files will not be managed by the script - in particular they will not be automatically deleted. Default: $HOME/.rsync-time-backup", # noqa: E501
119120
)
120121
parser.add_argument(
@@ -175,6 +176,8 @@ def parse_arguments() -> argparse.Namespace: # pragma: no cover
175176
if args.exclude_from:
176177
args.exclusion_file = args.exclude_from
177178

179+
args._auto_delete_log = args.log_dir == log_dir_default
180+
178181
return args
179182

180183

@@ -397,6 +400,10 @@ async def async_run_cmd(
397400

398401
await process.wait()
399402
assert process.returncode is not None, "Process has not returned"
403+
404+
if VERBOSE and process.returncode != 0:
405+
msg = style(str(process.returncode), "red", bold=True)
406+
log_error(f"Command exit code: {msg}")
400407
return CmdResult(stdout, stderr, process.returncode)
401408

402409

@@ -902,7 +909,7 @@ def main() -> None:
902909
dest_folder=args.dest_folder,
903910
exclusion_file=args.exclusion_file,
904911
log_dir=os.path.expandvars(os.path.expanduser(args.log_dir)),
905-
auto_delete_log=True,
912+
auto_delete_log=args._auto_delete_log,
906913
expiration_strategy=args.strategy,
907914
auto_expire=not args.no_auto_expire,
908915
port=args.port,

0 commit comments

Comments
 (0)