mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-07 21:00:49 +08:00
Merge 02064cb6e5 into d9a76cf66e
This commit is contained in:
commit
97e37fc254
@ -117,10 +117,27 @@ class ModelFileManager:
|
||||
# TODO use settings
|
||||
include_hidden_files = False
|
||||
|
||||
# Check if we should skip following symlinks
|
||||
from comfy.cli_args import args
|
||||
skip_symlinks = getattr(args, 'skip_symlink_scan', False)
|
||||
followlinks = not skip_symlinks
|
||||
|
||||
result: list[str] = []
|
||||
dirs: dict[str, float] = {}
|
||||
|
||||
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True):
|
||||
for dirpath, subdirs, filenames in os.walk(directory, followlinks=followlinks, topdown=True):
|
||||
# If skipping symlinks, filter out symlinked directories
|
||||
if skip_symlinks:
|
||||
filtered_subdirs = []
|
||||
for d in subdirs:
|
||||
subdir_path = os.path.join(dirpath, d)
|
||||
# Check if it's a symlink
|
||||
if os.path.islink(subdir_path):
|
||||
logging.debug(f"Skipping symlink: {subdir_path}")
|
||||
continue
|
||||
filtered_subdirs.append(d)
|
||||
subdirs[:] = filtered_subdirs
|
||||
|
||||
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names]
|
||||
if not include_hidden_files:
|
||||
subdirs[:] = [d for d in subdirs if not d.startswith(".")]
|
||||
|
||||
@ -232,6 +232,8 @@ database_default_path = os.path.abspath(
|
||||
)
|
||||
parser.add_argument("--database-url", type=str, default=f"sqlite:///{database_default_path}", help="Specify the database URL, e.g. for an in-memory database you can use 'sqlite:///:memory:'.")
|
||||
|
||||
parser.add_argument("--skip-symlink-scan", action="store_true", help="Skip following symlinks when scanning directories. Useful when symlinks point to network paths with many files. Specifying a filename directly will still work.")
|
||||
|
||||
if comfy.options.args_parsing:
|
||||
args = parser.parse_args()
|
||||
else:
|
||||
|
||||
@ -307,6 +307,10 @@ def recursive_search(directory: str, excluded_dir_names: list[str] | None=None)
|
||||
if excluded_dir_names is None:
|
||||
excluded_dir_names = []
|
||||
|
||||
# Check if we should skip following symlinks
|
||||
skip_symlinks = getattr(args, 'skip_symlink_scan', False)
|
||||
followlinks = not skip_symlinks
|
||||
|
||||
result = []
|
||||
dirs = {}
|
||||
|
||||
@ -321,7 +325,19 @@ def recursive_search(directory: str, excluded_dir_names: list[str] | None=None)
|
||||
subdirs: list[str]
|
||||
filenames: list[str]
|
||||
|
||||
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True):
|
||||
for dirpath, subdirs, filenames in os.walk(directory, followlinks=followlinks, topdown=True):
|
||||
# If skipping symlinks, filter out symlinked directories
|
||||
if skip_symlinks:
|
||||
filtered_subdirs = []
|
||||
for d in subdirs:
|
||||
subdir_path = os.path.join(dirpath, d)
|
||||
# Check if it's a symlink
|
||||
if os.path.islink(subdir_path):
|
||||
logging.debug(f"Skipping symlink: {subdir_path}")
|
||||
continue
|
||||
filtered_subdirs.append(d)
|
||||
subdirs[:] = filtered_subdirs
|
||||
|
||||
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names]
|
||||
for file_name in filenames:
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user