| 1 |
|
| 2 |
"""Coverage of -H across directory boundaries. |
| 3 |
|
| 4 |
hardlinks_test.py exercises -H on sibling files at the tree root; this |
| 5 |
companion checks that -H preserves a hard link whose two names live in |
| 6 |
DIFFERENT directories several levels deep (the cross-directory case the |
| 7 |
resolver restructure touches), and that without -H the names become |
| 8 |
independent inodes. |
| 9 |
""" |
| 10 |
|
| 11 |
from rsyncfns import ( |
| 12 |
FROMDIR, TODIR, |
| 13 |
assert_hardlinked, assert_not_hardlinked, makepath, rmtree, run_rsync, |
| 14 |
) |
| 15 |
import os |
| 16 |
|
| 17 |
src = FROMDIR |
| 18 |
a = os.path.join('a', 'aa', 'orig') |
| 19 |
b = os.path.join('b', 'bb', 'hardlink') |
| 20 |
|
| 21 |
rmtree(src) |
| 22 |
rmtree(TODIR) |
| 23 |
makepath(src / 'a' / 'aa', src / 'b' / 'bb') |
| 24 |
(src / a).write_text("shared content across directories\n") |
| 25 |
os.link(src / a, src / b) |
| 26 |
|
| 27 |
|
| 28 |
run_rsync('-aH', f'{src}/', f'{TODIR}/') |
| 29 |
assert_hardlinked(TODIR / a, TODIR / b, label='-H cross-dir hardlink') |
| 30 |
|
| 31 |
|
| 32 |
rmtree(TODIR) |
| 33 |
run_rsync('-a', f'{src}/', f'{TODIR}/') |
| 34 |
assert_not_hardlinked(TODIR / a, TODIR / b, label='no -H => separate inodes') |
| 35 |
|
| 36 |
print("hardlinks-deep: -H preserves a cross-directory hard link at depth") |