| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
import subprocess |
| 26 |
|
| 27 |
from rsyncfns import ( |
| 28 |
SCRATCHDIR, makepath, rmtree, rsync_argv, start_test_daemon, test_fail, |
| 29 |
test_xfail, write_daemon_conf, |
| 30 |
) |
| 31 |
|
| 32 |
DAEMON_PORT = 12910 |
| 33 |
|
| 34 |
mod = SCRATCHDIR / 'recvmod910' |
| 35 |
src = SCRATCHDIR / 'src910' |
| 36 |
rmtree(mod) |
| 37 |
rmtree(src) |
| 38 |
makepath(mod / 'ghostdir', src) |
| 39 |
(src / 'keep.txt').write_text("keep-me\n") |
| 40 |
(mod / 'keep.txt').write_text("stale\n") |
| 41 |
(mod / 'ghost.txt').write_text("delete-me-file\n") |
| 42 |
(mod / 'ghostdir' / 'inner').write_text("delete-me-dir\n") |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
flist = SCRATCHDIR / 'files910.lst' |
| 47 |
flist.write_text("keep.txt\nghost.txt\nghostdir\n") |
| 48 |
|
| 49 |
conf = write_daemon_conf([ |
| 50 |
('recv', {'path': str(mod), 'read only': 'no'}), |
| 51 |
]) |
| 52 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 53 |
|
| 54 |
proc = subprocess.run( |
| 55 |
rsync_argv('-a', '--delete', '--delete-missing-args', |
| 56 |
f'--files-from={flist}', f'{src}/', f'{url}recv/'), |
| 57 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) |
| 58 |
out = proc.stdout or '' |
| 59 |
print(out) |
| 60 |
|
| 61 |
|
| 62 |
if 'invalid file mode' in out or (proc.returncode == 2 and (mod / 'ghost.txt').exists()): |
| 63 |
test_xfail( |
| 64 |
"#910: --delete-missing-args with --files-from aborts with " |
| 65 |
"`invalid file mode 00 ... protocol incompatibility (code 2)`. The " |
| 66 |
"sender sends mode-0 entries for the missing args (the delete signal), " |
| 67 |
"but recv_file_entry()'s 3.4.x mode-validation rejects mode 0 before the " |
| 68 |
"generator can delete them. To be closed by accepting the " |
| 69 |
"missing-args mode-0 entry in recv_file_entry().") |
| 70 |
|
| 71 |
|
| 72 |
if proc.returncode != 0: |
| 73 |
test_fail(f"transfer failed unexpectedly (rc={proc.returncode}); " |
| 74 |
f"not the #910 mode-00 symptom:\n{out}") |
| 75 |
if (mod / 'ghost.txt').exists(): |
| 76 |
test_fail("missing-arg file ghost.txt was not deleted on the receiver") |
| 77 |
if (mod / 'ghostdir').exists(): |
| 78 |
test_fail("missing-arg directory ghostdir was not deleted on the receiver") |
| 79 |
if not (mod / 'keep.txt').is_file() or (mod / 'keep.txt').read_text() != "keep-me\n": |
| 80 |
test_fail("present file keep.txt was not delivered/updated correctly") |