bug with written_files_count in backup rsync+ssh module

This commit is contained in:
Yohannès ALEMU 2019-01-03 15:47:22 +01:00
parent e701575525
commit 8aa63dbdd4

View File

@ -170,15 +170,20 @@ class backup_rsync(backup_generic):
log = monitor_stdout(process,ondata,self) log = monitor_stdout(process,ondata,self)
reg_total_files = re.compile('Number of files: (?P<file>\d+)')
reg_transferred_files = re.compile('Number of .*files transferred: (?P<file>\d+)')
for l in log.splitlines(): for l in log.splitlines():
if l.startswith('Number of files:'): line = l.replace(',','')
stats['total_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1])) m = reg_total_files.match(line)
if l.startswith('Number of files transferred:'): if m:
stats['written_files_count'] += int(re.sub("[^0-9]", "", l.split(':')[1])) stats['total_files_count'] += int(m.groupdict()['file'])
if l.startswith('Total file size:'): m = reg_transferred_files.match(line)
stats['total_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0])) if m:
if l.startswith('Total transferred file size:'): stats['written_files_count'] += int(m.groupdict()['file'])
stats['written_bytes'] += int(re.sub("[^0-9]", "", l.split(':')[1].split()[0])) if line.startswith('Total file size:'):
stats['total_bytes'] += int(line.split(':')[1].split()[0])
if line.startswith('Total transferred file size:'):
stats['written_bytes'] += int(line.split(':')[1].split()[0])
returncode = process.returncode returncode = process.returncode
## deal with exit code 24 (file vanished) ## deal with exit code 24 (file vanished)