From 3f3af9622474dab41051b09d0053d3e590686de0 Mon Sep 17 00:00:00 2001 From: grymphen Date: Sun, 10 May 2026 16:26:21 +0200 Subject: [PATCH] sync errors --- sftp.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sftp.py b/sftp.py index 0d49b88..fb15577 100644 --- a/sftp.py +++ b/sftp.py @@ -83,6 +83,7 @@ def list_new_zips(cfg: SFTPConfig) -> list[RemoteZip]: transport = _make_transport(cfg) sftp = paramiko.SFTPClient.from_transport(transport) try: + log.info("Walking remote directory tree from %s ...", cfg.remote_path) all_zips = _walk_zips(sftp, cfg.remote_path) new_zips = [z for z in all_zips if not db.is_zip_processed(z.remote_path)] log.info("Remote: %d zip(s) total, %d new", len(all_zips), len(new_zips)) @@ -109,16 +110,24 @@ def download(cfg: SFTPConfig, remote_zip: RemoteZip, dest_dir: str) -> Path: def _walk_zips(sftp: paramiko.SFTPClient, remote_dir: str) -> list[RemoteZip]: results: list[RemoteZip] = [] + log.info("Listing %s ...", remote_dir) try: entries = sftp.listdir_attr(remote_dir) except IOError as e: log.warning("Cannot list %s: %s", remote_dir, e) return results + subdirs = [] + zips_here = 0 for entry in entries: full_path = posixpath.join(remote_dir, entry.filename) if stat.S_ISDIR(entry.st_mode): - results.extend(_walk_zips(sftp, full_path)) + subdirs.append(full_path) elif entry.filename.lower().endswith(".zip"): results.append(RemoteZip(remote_path=full_path, file_size=entry.st_size or 0)) + zips_here += 1 + + log.info(" %s: %d entries, %d zip(s), %d subdir(s)", remote_dir, len(entries), zips_here, len(subdirs)) + for subdir in subdirs: + results.extend(_walk_zips(sftp, subdir)) return results