From d64ea61be759d2a08f101ed479d54e421cf846e7 Mon Sep 17 00:00:00 2001 From: taoky Date: Tue, 27 Aug 2024 18:46:19 +0800 Subject: [PATCH] Only do one stat() for packages when sync-packages is on in verification step 3 Related: #4 --- shadowmire.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shadowmire.py b/shadowmire.py index c671b25..2bb13d4 100755 --- a/shadowmire.py +++ b/shadowmire.py @@ -556,12 +556,14 @@ class SyncBase: should_update = False for href, size in hrefsize_json: dest = Path(normpath(package_simple_path / href)) - if not dest.exists(): + try: + dest_stat = dest.stat() + except FileNotFoundError: logger.info("add %s as it's missing packages", package_name) should_update = True break if compare_size and size != -1: - dest_size = dest.stat().st_size + dest_size = dest_stat.st_size if dest_size != size: logger.info( "add %s as its local size %s != %s",