Compare commits

...

6 Commits

Author SHA1 Message Date
V1sionVerse
ae17663874
Merge 1f11b200cd into b08debceca 2026-07-06 17:34:08 +08:00
V1sionVerse
1f11b200cd
Merge branch 'master' into image-upload-file-size-check 2026-03-25 12:19:01 +01:00
V1sionVerse
e50a36e05c
Removed whitespace from blank line 2026-03-17 16:36:29 +01:00
V1sionVerse
9ef776b689
Removed trailing whitespace 2026-03-17 16:31:12 +01:00
V1sionVerse
bc5932daaf
Merge branch 'Comfy-Org:master' into image-upload-file-size-check 2026-03-17 10:10:32 +01:00
V1sionVerse
6e5700aad0
Improved performance of image_upload() in server.py
Added a cheap file size comparison before the expensive file hash comparison.
This should considerably improve average-case performance.
2026-03-16 09:23:02 +01:00

View File

@ -420,11 +420,19 @@ class PromptServer():
if overwrite is not None and (overwrite == "true" or overwrite == "1"):
pass
else:
# Get uploaded file size once
image.file.seek(0, 2) # Seek to end
uploaded_size = image.file.tell()
image.file.seek(0) # Reset to beginning
i = 1
while os.path.exists(filepath):
if compare_image_hash(filepath, image): #compare hash to prevent saving of duplicates with same name, fix for #3465
image_is_duplicate = True
break
# Quick size comparison first
existing_size = os.path.getsize(filepath)
if existing_size == uploaded_size:
if compare_image_hash(filepath, image): #compare hash to prevent saving of duplicates with same name, fix for #3465
image_is_duplicate = True
break
filename = f"{split[0]} ({i}){split[1]}"
filepath = os.path.join(full_output_folder, filename)
i += 1