From b0505eb7ab8af1986dabd97c23fae83a0539303d Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sat, 13 May 2023 15:31:22 -0400 Subject: [PATCH] Return right type when none specified in upload route. Switch time.time to time.perf_counter for custom node import times. --- nodes.py | 4 ++-- server.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nodes.py b/nodes.py index 63d9adc3..c4aff101 100644 --- a/nodes.py +++ b/nodes.py @@ -1338,9 +1338,9 @@ def load_custom_nodes(): for possible_module in possible_modules: module_path = os.path.join(custom_node_path, possible_module) if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue - time_before = time.time() + time_before = time.perf_counter() success = load_custom_node(module_path) - node_import_times.append((time.time() - time_before, module_path, success)) + node_import_times.append((time.perf_counter() - time_before, module_path, success)) if len(node_import_times) > 0: print("\nImport times for custom nodes:") diff --git a/server.py b/server.py index d1079dd8..ba4dcba0 100644 --- a/server.py +++ b/server.py @@ -115,22 +115,23 @@ class PromptServer(): def get_dir_by_type(dir_type): if dir_type is None: - type_dir = folder_paths.get_input_directory() - elif dir_type == "input": + dir_type = "input" + + if dir_type == "input": type_dir = folder_paths.get_input_directory() elif dir_type == "temp": type_dir = folder_paths.get_temp_directory() elif dir_type == "output": type_dir = folder_paths.get_output_directory() - return type_dir + return type_dir, dir_type def image_upload(post, image_save_function=None): image = post.get("image") overwrite = post.get("overwrite") image_upload_type = post.get("type") - upload_dir = get_dir_by_type(image_upload_type) + upload_dir, image_upload_type = get_dir_by_type(image_upload_type) if image and image.file: filename = image.filename