mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-16 16:43:36 +00:00
Frontend Manager: avoid redundant gh calls for static versions (#5152)
* Frontend Manager: avoid redundant gh calls for static versions * actually, removing old tmpdir isn't needed I tested - downloader code handles this case well already (also rmdir was wrong func anyway, needed shutil.rmtree if it had content) * add code comment
This commit is contained in:
parent
0dbba9f751
commit
c695c4af7f
@ -151,6 +151,15 @@ class FrontendManager:
|
|||||||
return cls.DEFAULT_FRONTEND_PATH
|
return cls.DEFAULT_FRONTEND_PATH
|
||||||
|
|
||||||
repo_owner, repo_name, version = cls.parse_version_string(version_string)
|
repo_owner, repo_name, version = cls.parse_version_string(version_string)
|
||||||
|
|
||||||
|
if version.startswith("v"):
|
||||||
|
expected_path = str(Path(cls.CUSTOM_FRONTENDS_ROOT) / f"{repo_owner}_{repo_name}" / version.lstrip("v"))
|
||||||
|
if os.path.exists(expected_path):
|
||||||
|
logging.info(f"Using existing copy of specific frontend version tag: {repo_owner}/{repo_name}@{version}")
|
||||||
|
return expected_path
|
||||||
|
|
||||||
|
logging.info(f"Initializing frontend: {repo_owner}/{repo_name}@{version}, requesting version details from GitHub...")
|
||||||
|
|
||||||
provider = provider or FrontEndProvider(repo_owner, repo_name)
|
provider = provider or FrontEndProvider(repo_owner, repo_name)
|
||||||
release = provider.get_release(version)
|
release = provider.get_release(version)
|
||||||
|
|
||||||
@ -159,16 +168,20 @@ class FrontendManager:
|
|||||||
Path(cls.CUSTOM_FRONTENDS_ROOT) / provider.folder_name / semantic_version
|
Path(cls.CUSTOM_FRONTENDS_ROOT) / provider.folder_name / semantic_version
|
||||||
)
|
)
|
||||||
if not os.path.exists(web_root):
|
if not os.path.exists(web_root):
|
||||||
|
# Use tmp path until complete to avoid path exists check passing from interrupted downloads
|
||||||
|
tmp_path = web_root + ".tmp"
|
||||||
try:
|
try:
|
||||||
os.makedirs(web_root, exist_ok=True)
|
os.makedirs(tmp_path, exist_ok=True)
|
||||||
logging.info(
|
logging.info(
|
||||||
"Downloading frontend(%s) version(%s) to (%s)",
|
"Downloading frontend(%s) version(%s) to (%s)",
|
||||||
provider.folder_name,
|
provider.folder_name,
|
||||||
semantic_version,
|
semantic_version,
|
||||||
web_root,
|
tmp_path,
|
||||||
)
|
)
|
||||||
logging.debug(release)
|
logging.debug(release)
|
||||||
download_release_asset_zip(release, destination_path=web_root)
|
download_release_asset_zip(release, destination_path=tmp_path)
|
||||||
|
if os.listdir(tmp_path):
|
||||||
|
os.rename(tmp_path, web_root)
|
||||||
finally:
|
finally:
|
||||||
# Clean up the directory if it is empty, i.e. the download failed
|
# Clean up the directory if it is empty, i.e. the download failed
|
||||||
if not os.listdir(web_root):
|
if not os.listdir(web_root):
|
||||||
|
Loading…
Reference in New Issue
Block a user