The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
fix: atomic writes for userdata to prevent data loss on crash (#12987)
Christian Byrne9a870b5102fa
diff --git a/app/user_manager.py b/app/user_manager.pyindex e2c00dab2..e18afb71b 100644--- a/app/user_manager.py+++ b/app/user_manager.py@@ -6,6 +6,7 @@ import uuidimport globimport shutilimport logging+import tempfilefrom aiohttp import webfrom urllib import parsefrom comfy.cli_args import args@@ -377,8 +378,15 @@ class UserManager():try:body = await request.read()- with open(path, "wb") as f:- f.write(body)+ dir_name = os.path.dirname(path)+ fd, tmp_path = tempfile.mkstemp(dir=dir_name)+ try:+ with os.fdopen(fd, "wb") as f:+ f.write(body)+ os.replace(tmp_path, path)+ except:+ os.unlink(tmp_path)+ raiseexcept OSError as e:logging.warning(f"Error saving file '{path}': {e}")return web.Response(