From 2543b0fc0bce744f436cb228ca96aa04be6bc838 Mon Sep 17 00:00:00 2001 From: Zenithal Date: Sat, 4 Sep 2021 22:34:27 +0800 Subject: [PATCH] apt-sync: fix deep pkgidx_file download error: no parent dir only dist_tmp_dir, comp_tmp_dir and pkgidx_tmp_dir are created and garbage collected, for deep pkgidx_file like main/dep11/by-hash/MD5Sum/0af5c69679a24671cfd7579095a9cb5e, its tmp parent dir (we call it deep_tmp_dir) should be created, at main/dep11/.tmp/by-hash/MD5Sum/0af5c69679a24671cfd7579095a9cb5e --- apt-sync.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apt-sync.py b/apt-sync.py index ba009c6..24f165d 100755 --- a/apt-sync.py +++ b/apt-sync.py @@ -145,7 +145,17 @@ def apt_mirror(base_url: str, dist: str, repo: str, arch: str, dest_base_dir: Pa filename.startswith(f"{repo}/Contents-{arch}") or \ filename.startswith(f"Contents-{arch}"): fn = Path(filename) - pkgidx_file = dist_dir / fn.parent / ".tmp" / fn.name + if len(fn.parts) <= 3: + # Contents-amd64.gz + # main/Contents-amd64.gz + # main/binary-all/Packages + pkgidx_file = dist_dir / fn.parent / ".tmp" / fn.name + else: + # main/dep11/by-hash/MD5Sum/0af5c69679a24671cfd7579095a9cb5e + # deep_tmp_dir is in pkgidx_tmp_dir hence no extra garbage collection needed + deep_tmp_dir = dist_dir / Path(fn.parts[0]) / Path(fn.parts[1]) / ".tmp" / Path('/'.join(fn.parts[2:-1])) + deep_tmp_dir.mkdir(parents=True, exist_ok=True) + pkgidx_file = deep_tmp_dir / fn.name else: print(f"Ignore the file {filename}") continue