Keep only rsync's summary lines when not verbose
Every output line was kept in memory although only the last two were logged, and fewer than two lines (e.g. with --rsync-options q) raised an IndexError.
This commit is contained in:
@@ -24,6 +24,7 @@ import re
|
||||
import shlex
|
||||
import sys
|
||||
import warnings
|
||||
from collections import deque
|
||||
from collections.abc import Callable, Iterator
|
||||
from datetime import datetime
|
||||
from functools import wraps
|
||||
@@ -774,7 +775,8 @@ class Backup:
|
||||
assert p.stdin is not None and isinstance(p.stdout, io.BufferedIOBase)
|
||||
p.stdin.close()
|
||||
|
||||
output = []
|
||||
# Without -v, only the summary (the last two lines) is logged
|
||||
output: list[str] | deque[str] = [] if self._verbose else deque(maxlen=2)
|
||||
|
||||
try:
|
||||
for r in _read_records(p.stdout):
|
||||
@@ -790,8 +792,9 @@ class Backup:
|
||||
if self._verbose:
|
||||
logger.info('rsync: %s', output)
|
||||
else:
|
||||
logger.info('rsync: %s', output[-2])
|
||||
logger.info('rsync: %s', output[-1])
|
||||
# May be fewer than two lines, e.g. with --rsync-options q
|
||||
for r in output:
|
||||
logger.info('rsync: %s', r)
|
||||
else:
|
||||
self._returncode_log(returncode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user