From 7d528b1b4d88e29a3ef95f02927467f81ccd2ad9 Mon Sep 17 00:00:00 2001 From: TapTap Date: Sun, 5 Jul 2026 19:06:25 +0200 Subject: [PATCH] test: use temp dir for rsync error retry --- test.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test.py b/test.py index 851e08a..b1304bc 100755 --- a/test.py +++ b/test.py @@ -361,14 +361,18 @@ read only = yes errors.append(f"Exit code {rsync_result.returncode}: {err[:200]}") # Retry without systemd-run to reveal the actual error if client_prefix: - plain = subprocess.run( - ["rsync", "-aH", f"rsync://localhost:{rsync_port}/source/", "/tmp/"], - capture_output=True, text=True, timeout=30 - ) - if plain.returncode != 0: - plain_errs = [l for l in (plain.stderr or "").split("\n") if l.strip()] - if plain_errs: - errors.append(f"raw: {plain_errs[-1][:150]}") + tmp_dest = tempfile.mkdtemp() + try: + plain = subprocess.run( + ["rsync", "-aH", f"rsync://localhost:{rsync_port}/source/", f"{tmp_dest}/"], + capture_output=True, text=True, timeout=30 + ) + if plain.returncode != 0: + plain_errs = [l for l in (plain.stderr or "").split("\n") if l.strip()] + if plain_errs: + errors.append(f"raw: {plain_errs[-1][:150]}") + finally: + shutil.rmtree(tmp_dest, ignore_errors=True) if missing: errors.append(f"Missing ({len(missing)}): {', '.join(missing[:5])}") if mismatches: