Skip to content

Commit

Permalink
fix: expansions files copy #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Seedsa committed Jul 3, 2024
1 parent 9dd9416 commit 0db7c05
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""
This module initializes and sets up the Fooocus extension for ComfyUI.
It handles folder creation, file downloads, and node mapping for the extension.
"""

import os
import importlib
import shutil
import folder_paths

import filecmp

def create_folder_and_update_paths(folder_name):
folder_path = os.path.join(folder_paths.models_dir, folder_name)
Expand Down Expand Up @@ -46,6 +51,25 @@ def create_folder_and_update_paths(folder_name):
WEB_DIRECTORY = "./web"


def recursive_overwrite(src, dest, ignore=None):
if os.path.isdir(src):
if not os.path.isdir(dest):
os.makedirs(dest)
files = os.listdir(src)
if ignore is not None:
ignored = ignore(src, files)
else:
ignored = set()
for f in files:
if f not in ignored:
recursive_overwrite(os.path.join(src, f),
os.path.join(dest, f),
ignore)
else:
if not os.path.exists(dest) or not filecmp.cmp(src, dest):
shutil.copyfile(src, dest)
log.log_node_info(f'Copying file from {src} to {dest}')

def get_ext_dir(subpath=None, mkdir=False):
dir = os.path.dirname(__file__)
if subpath is not None:
Expand All @@ -63,8 +87,8 @@ def install_expansion():
"prompt_expansion is not exists. Please reinstall the extension.")
return
if not os.path.exists(fooocus_expansion_path):
log.log_node_info('Copying Prompt Expansion files')
shutil.copytree(src_dir, fooocus_expansion_path, dirs_exist_ok=True)
os.makedirs(fooocus_expansion_path)
recursive_overwrite(src_dir, fooocus_expansion_path)


def download_models():
Expand Down

0 comments on commit 0db7c05

Please sign in to comment.