This commit is contained in:
psychedelicious 2022-10-29 11:10:48 +11:00
parent 0b046c95ef
commit 6fb6bc6d7f

View File

@ -441,7 +441,8 @@ class InvokeAIWebServer:
print(path) print(path)
send2trash(path) send2trash(path)
socketio.emit( socketio.emit(
"imageDeleted", {"url": url, "uuid": uuid, "category": category} "imageDeleted",
{"url": url, "uuid": uuid, "category": category},
) )
except Exception as e: except Exception as e:
self.socketio.emit("error", {"message": (str(e))}) self.socketio.emit("error", {"message": (str(e))})
@ -988,7 +989,11 @@ class InvokeAIWebServer:
): ):
try: try:
pngwriter = PngWriter(output_dir) pngwriter = PngWriter(output_dir)
prefix = pngwriter.unique_prefix()
number_prefix = pngwriter.unique_prefix()
uuid = uuid4().hex
truncated_uuid = uuid[:8]
seed = "unknown_seed" seed = "unknown_seed"
@ -996,7 +1001,7 @@ class InvokeAIWebServer:
if "seed" in metadata["image"]: if "seed" in metadata["image"]:
seed = metadata["image"]["seed"] seed = metadata["image"]["seed"]
filename = f"{prefix}.{seed}" filename = f"{number_prefix}.{truncated_uuid}.{seed}"
if step_index: if step_index:
filename += f".{step_index}" filename += f".{step_index}"
@ -1100,12 +1105,18 @@ class InvokeAIWebServer:
def save_file_unique_uuid_name(self, bytes, name, path): def save_file_unique_uuid_name(self, bytes, name, path):
try: try:
uuid = uuid4().hex uuid = uuid4().hex
truncated_uuid = uuid[:8]
split = os.path.splitext(name) split = os.path.splitext(name)
name = f"{split[0]}.{uuid}{split[1]}" name = f"{split[0]}.{truncated_uuid}{split[1]}"
file_path = os.path.join(path, name) file_path = os.path.join(path, name)
os.makedirs(os.path.dirname(file_path), exist_ok=True) os.makedirs(os.path.dirname(file_path), exist_ok=True)
newFile = open(file_path, "wb") newFile = open(file_path, "wb")
newFile.write(bytes) newFile.write(bytes)
return file_path return file_path
except Exception as e: except Exception as e:
self.socketio.emit("error", {"message": (str(e))}) self.socketio.emit("error", {"message": (str(e))})