| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import shutil |
| 16 |
import subprocess |
| 17 |
|
| 18 |
from rsyncfns import ( |
| 19 |
SCRATCHDIR, make_data_file, makepath, rmtree, rsync_argv, start_test_daemon, |
| 20 |
test_fail, write_daemon_conf, |
| 21 |
) |
| 22 |
|
| 23 |
DAEMON_PORT = 12931 |
| 24 |
DATA_SIZE = 40000 |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
base = SCRATCHDIR / 'bakroot' |
| 30 |
src = SCRATCHDIR / 'srcroot' |
| 31 |
rmtree(base) |
| 32 |
rmtree(src) |
| 33 |
makepath(base / '01', src) |
| 34 |
make_data_file(src / 'f.dat', DATA_SIZE) |
| 35 |
shutil.copy2(src / 'f.dat', base / '01' / 'f.dat') |
| 36 |
|
| 37 |
conf = write_daemon_conf([ |
| 38 |
('root', {'path': '/', 'read only': 'no'}), |
| 39 |
]) |
| 40 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 41 |
|
| 42 |
base_rel = str(base).lstrip('/') |
| 43 |
rmtree(base / '00') |
| 44 |
proc = subprocess.run( |
| 45 |
rsync_argv('-a', '--link-dest=../01', f'{src}/', f'{url}root/{base_rel}/00/'), |
| 46 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) |
| 47 |
out = proc.stdout or '' |
| 48 |
if proc.returncode != 0: |
| 49 |
test_fail(f"path=/ --link-dest push failed unexpectedly (rc={proc.returncode}):\n{out}") |
| 50 |
|
| 51 |
dest = base / '00' / 'f.dat' |
| 52 |
basis = base / '01' / 'f.dat' |
| 53 |
if not dest.is_file(): |
| 54 |
test_fail(f"destination file missing ({dest})") |
| 55 |
|
| 56 |
ds, bs = dest.stat(), basis.stat() |
| 57 |
if (ds.st_dev, ds.st_ino) != (bs.st_dev, bs.st_ino): |
| 58 |
test_fail( |
| 59 |
"#915 (path=/ case): a `path = /` daemon module ignored --link-dest=../01 " |
| 60 |
"(module_dirlen==0 skipped the re-anchor) -- the file was re-transferred " |
| 61 |
"instead of hard-linked. The secure walk must honour the in-module climb.") |
| 62 |
|