| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
import os |
| 10 |
import shutil |
| 11 |
import time |
| 12 |
|
| 13 |
from rsyncfns import ( |
| 14 |
CHKDIR, FROMDIR, RSYNC, RSYNC_PEER, SCRATCHDIR, SRCDIR, TMPDIR, TODIR, |
| 15 |
checkit, hands_setup, rmtree, run_rsync, test_fail, rsync_path_arg, rsh_cmd, |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
alt1dir = TMPDIR / 'alt1' |
| 20 |
alt2dir = TMPDIR / 'alt2' |
| 21 |
alt3dir = TMPDIR / 'alt3' |
| 22 |
|
| 23 |
SSH = rsh_cmd() |
| 24 |
|
| 25 |
hands_setup() |
| 26 |
|
| 27 |
|
| 28 |
run_rsync('-av', '--include=text', '--include=*/', '--exclude=*', |
| 29 |
f'{FROMDIR}/', f'{alt1dir}/') |
| 30 |
run_rsync('-av', '--include=etc-ltr-list', '--include=*/', '--exclude=*', |
| 31 |
f'{FROMDIR}/', f'{alt2dir}/') |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
(FROMDIR / 'likely').write_text("This is a test file\n") |
| 36 |
alt3dir.mkdir() |
| 37 |
(alt3dir / 'likely').write_text("This is a test file\n") |
| 38 |
|
| 39 |
time.sleep(1) |
| 40 |
os.utime(FROMDIR / 'dir' / 'text') |
| 41 |
os.utime(FROMDIR / 'likely') |
| 42 |
|
| 43 |
|
| 44 |
run_rsync('-av', '--exclude=/text', '--exclude=etc-ltr-list', |
| 45 |
f'{FROMDIR}/', f'{CHKDIR}/') |
| 46 |
|
| 47 |
|
| 48 |
checkit(['-avv', '--no-whole-file', |
| 49 |
f'--compare-dest={alt1dir}', f'--compare-dest={alt2dir}', |
| 50 |
f'{FROMDIR}/', f'{TODIR}/'], CHKDIR, TODIR) |
| 51 |
|
| 52 |
rmtree(TODIR) |
| 53 |
|
| 54 |
|
| 55 |
checkit(['-avv', '--no-whole-file', |
| 56 |
f'--copy-dest={alt1dir}', f'--copy-dest={alt2dir}', |
| 57 |
f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR) |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
for maybe_inplace in ([], ['--inplace']): |
| 62 |
rmtree(TODIR) |
| 63 |
checkit(['-av', *maybe_inplace, f'--copy-dest={alt3dir}', |
| 64 |
f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR) |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
if os.stat(TODIR / 'likely').st_ino == os.stat(alt3dir / 'likely').st_ino: |
| 70 |
test_fail(f"--copy-dest{' --inplace' if maybe_inplace else ''} " |
| 71 |
"hard-linked 'likely' instead of copying it") |
| 72 |
|
| 73 |
for srchost in ('', 'localhost:'): |
| 74 |
desthost = 'localhost:' if not srchost else '' |
| 75 |
rmtree(TODIR) |
| 76 |
checkit(['-ave', SSH, f'--rsync-path={rsync_path_arg()}', *maybe_inplace, |
| 77 |
f'--copy-dest={alt3dir}', |
| 78 |
f'{srchost}{FROMDIR}/', f'{desthost}{TODIR}/'], |
| 79 |
FROMDIR, TODIR) |