Only do one stat() for packages when sync-packages is on in verification step 3

Related: #4
This commit is contained in:
taoky 2024-08-27 18:46:19 +08:00
parent f4927fdb0d
commit d64ea61be7

View File

@ -556,12 +556,14 @@ class SyncBase:
should_update = False should_update = False
for href, size in hrefsize_json: for href, size in hrefsize_json:
dest = Path(normpath(package_simple_path / href)) 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) logger.info("add %s as it's missing packages", package_name)
should_update = True should_update = True
break break
if compare_size and size != -1: if compare_size and size != -1:
dest_size = dest.stat().st_size dest_size = dest_stat.st_size
if dest_size != size: if dest_size != size:
logger.info( logger.info(
"add %s as its local size %s != %s", "add %s as its local size %s != %s",