Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ void generate_files(int f_out, const char *local_name)
write_ndx(f_out, NDX_DONE);

if (protocol_version >= 31 && EARLY_DELETE_DONE_MSG()) {
if ((INFO_GTE(STATS, 2) && (delete_mode || force_delete)) || read_batch)
if (delete_mode || force_delete || read_batch)
write_del_stats(f_out);
if (EARLY_DELAY_DONE_MSG()) /* Can't send this before delay */
write_ndx(f_out, NDX_DONE);
Expand Down Expand Up @@ -2429,7 +2429,7 @@ void generate_files(int f_out, const char *local_name)

if (protocol_version >= 31) {
if (!EARLY_DELETE_DONE_MSG()) {
if (INFO_GTE(STATS, 2) || read_batch)
if (delete_mode || force_delete || read_batch)
write_del_stats(f_out);
write_ndx(f_out, NDX_DONE);
}
Expand Down
43 changes: 43 additions & 0 deletions testsuite/daemon-delete-stats_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""Daemon upload delete stats report deleted files."""

import subprocess

from rsyncfns import (
FROMDIR, TODIR,
build_rsyncd_conf, makepath, rmtree, rsync_argv, start_test_daemon,
test_fail,
)


DAEMON_PORT = 12899

src = FROMDIR
dst = TODIR

rmtree(src)
rmtree(dst)
makepath(src, dst)

(src / 'keep.txt').write_text("keep\n")
(dst / 'keep.txt').write_text("keep\n")
(dst / 'delete.txt').write_text("delete\n")

url = start_test_daemon(build_rsyncd_conf(), DAEMON_PORT)

proc = subprocess.run(
rsync_argv('-a', '--delete', '-i', '--stats', f'{src}/', f'{url}test-to/'),
capture_output=True,
text=True,
)
out = proc.stdout + proc.stderr
print(out)

if proc.returncode != 0:
test_fail(f"daemon upload delete run exited {proc.returncode}")

if '*deleting delete.txt' not in out:
test_fail(f"daemon upload did not itemize the deleted file:\n{out}")

if 'Number of deleted files: 1 (reg: 1)' not in out:
test_fail(f"daemon upload did not report the deleted file in stats:\n{out}")